James Newkirk (of NUnit fame) gave a presentation at Tech·Ed Europe about the integration of unit testing into the software development lifecycle. Benjamin Mitchell took some good notes and posted them to his blog for those of us who couldn’t attend (thanks, Benjamin). Here are some of the highlights:
“He favors testing the public interface because it decouples the test from the implementation which will discourage refactoring.”
Not only do I agree with him, but I would add that your private behavior is likely exposed through a public interface anyway, and that’s where you should test.
“James said that he believes that testing has to be seen as a primary part of development. We have to incorporate test inside development.”
Amen! Using a tool like NUnit is most effective if it is used during development. Although I consider test-first the ideal, this is a radical idea for many people new to test-driven development, so writing any test is better than nothing.
“James mentioned that studies have show that Test First is 16% longer, but the quality was much higher.”
“James believed that if you are interacting with something complex, building the simulation of something that is complex is a worthless activity - you spend more time writing the simulator than the test and it doesn't tell you anything.”
Remember, we aren’t writing tests for testing’s sake. We’re writing tests to help us with design, development, refactoring, and confidence.
“James thinks looking at the implementation to drive the tests is looking at it the wrong way.”