RefactoringUnitTests

November 07, 2007
I thought this quote from a recent Larry O'Brien article summed it up nicely (keep in mind, the context is referring to TDD-ing a compiler - so the ‘multihour fixup’ he refers to may be specific to the problem at hand):
I don't like test suites refactored toward abstraction; one of the primary purposes of a test suite is as an aid to comprehending the system under test, and I think it's important that tests take as straight a path as possible between instantiation and system test. Personally, I would rather pay the price of an occasional multihour fixup during development than the price of a difficult-to-understand suite in 18 months.

And after discussing this a bit on the PragProg mailing list, I came to this good-sounding (but still under consideration) piece of advice:
Don't refactor your unit tests, refactor the code under test until the tests naturally become DRY.

tags: ComputersAndTechnology
comments powered by Disqus