Monday, December 1, 2008

Tests? We Don't Need No Stinking Tests!

I've been banging out test after test and it is so awesome to see the results. I'm still not fully doing TDD because its so new to me that I'm still writing a little code then a little test. Slowly but surely I'm starting to flip it around to doing a little test doing a little code. In fact, its been going so well that I've started to go refactor happy. I see some poorly written code, I write a test, make sure it passes and refactor. I know, I know, there should have been a test in place and writing tests for exiting code is dangerous because you tend to write the test to the code not the code to the test; but I have to do the best I can with a code base starting with 0% code coverage. Its now up to 1.3% that's not too bad considering there are 323,658 lines of code.

I think my skill with writing tests is starting to improve as well. I've read that when you first start to do TDD that you should aim for 100% code coverage but as I mature in my understanding of the goal and purpose of the tests, I've come to believe that 80% or more is acceptable. I test the crap out of classes that have serious business logic and I tend to only hit the happy path for classes that support that business logic.

By Friday I should be ready for my first iterative release. Since I don't have management buy off for XP I'm just going to release it to the Test environment and see if I can convince anyone else to take a look at it. Then maybe I can begin to convince people that seeing results sooner and making decisions on reality rather than on assumptions is far superior to how we've developed code in the past.

No comments: