Find a Defect, Write Tests


The XP discipline that Chet and I follow is that when we find a defect, we write a test that shows the defect and then fix it. The reasoning is that if our tests were good, there would be no defects. Therefore, our tests at this point are inadequate. We write the necessary tests, not so much for this defect, but instead to teach ourselves what kind of tests we need to add.

Heres the problem: this code is in the GUI, and we have no tests for the GUI. Our normal practice is to write very thin GUIs that dont require tests. If you never get a bug in the GUI, you can claim that this practice works. But we have a bug in the GUI. Now what?

I made the mistake of asking for advice on the Yahoo extreme programming mailing list. It was Dog Pile On Ron time! People from all over the world berated me for not having tests for this, calling my orthodoxy into question, threatening me with expulsion from the community. They even offered some advice on what to do, when I protested that I didnt know how to write this test.

I think much of the advice is good. However, even after a couple of short attempts, I havent been able to find steps that seem small enough to be safe. This is, for better or worse , untested code, and I dont feel comfortable making significant changes without tests. This morning Ive got an idea for something to try. Its a bigger step than Id like, but maybe its not too big.




Extreme Programming Adventures in C#
Javaв„ў EE 5 Tutorial, The (3rd Edition)
ISBN: 735619492
EAN: 2147483647
Year: 2006
Pages: 291

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net