Friday, April 29, 2011

Thoughts before Alt .NET Seattle: Part I: TDD

I am going to Alt.Net 2011 Seattle Conference next weekend. Since I am not on the bleeding edge of technology at work, I’m looking into modern methods and technologies.

TDD

On my last couple of gigs, when I bring up Test Driven Development, I get a lecture about how it is overly academic and would never work "here" (one place even banned NUnit altogether). Yes, it may take more time to code, but at these places, we spend a lot of time fixing things after the fact.

I agree that it can be taken too far. There are times that it doesn’t make sense to write test before writing trivial code. UI is infamously un-testable. Be pragmatic, it is just as extreme to reject automated testing altogether

I like the way TDD appears to make you think. You know, this function needs to do these 5 things, and what about this edge case, etc. And I have some tests that I can use later, for less effort than if wrote the test later.

I have snuck some tests into the projects that I have more control over. Most of the tests are too large (cover more one thing) and break other TDD rules. Since I can’t get approval to use an IOC container, they are not unit test. Even with these lower quality tests, I have found bugs and have been able to safely re-factor.

No comments: