Bug testing

jplindstrom on 2002-10-21T13:18:20

I know it's PK, and yes, I keep reiterating the same thing again and again...

But testing is really a useful thing.

"Hey, your Wiki mail interface doesn't recognize Wiki names when there is a colon after the name".

Oops...

Ok. I need to check if that's a correct bug report. So I write a test for that. I can do that because I already have tests for similar things. Without the previous tests, this would be difficult. But! Since I already have tests written, writing another test is the easiest way of checking this, because the feature is already broken out of the surrounding program. You don't have to pass it weird live data, or write an elaborate script faking this error condition. It's already done. True laziness.

And I write the test (it fails according to the bug report), fix the problem and all tests are go. And I feel cocky so I release it into the production environment (with the current working code properly backed up, I'm not suicidal :) without even running the entire program! And it works, because I already tested the part that I changed.

Aah, it's good that the right thing happens to be the easy way sometimes :)

The thing is this: often you need to try things out with small pieces of code; to see if what you did works the way you intended; to experiment. The thing with tests is that you take this code, that you wrote anyway, and actually use it for something good. I think that's why it works: you already did this, but now you do it in a formal way, with huge benefits.