Lots and lots of tests

Created: 2013/09/23 21:58:32+0000

When I write code I don't use test driven development. I do write tests. Unit tests and integration tests and tests where I don't bother to make a distinction. I do write plenty of them. This gives be two things:

  • Something to run my code
  • The ability to refactor and know if I changed something I shouldn't have

When I write code the first thing to run it are my tests. I don't worry about a test contract, I'm happy to rewrite the code and the test at this point. The tests just tell me what to expect. At this point I may start using what I've written.

I'm currently working on my web-utils project. My recent 0.2.6 release added user agent parsing. I pushed this out in a hurry so now I have a lot of refactoring to do. The second thing my tests give me is that I can make these changes without worrying. I noticed that in some of my code I had some deeply nested if statements. I rewrote them to flatten them out and relied on my tests to find where I had made changes I shouldn't have. It made it easy.