Check output automatically is a method for TacticalTesting.
One of the requirements of testing is to be able to do something
and make sure that you get the right result.
But we all know that because we write hard programs, it's hard to tell
whether the result is correct or not.
The first step is to provide better support.
The sort of stuff I am talking about is not rocket science, but it seems
that only automated testing requires it.
Here are some examples:
- check for object equality (so Java programmers have to implement .equals(), and so should Java class libraries)
- check for array equality
- check for array equality irrespective of order
- check that output contains certain patterns
Please tell me I have been looking in the wrong place for this sort of code.
-- JohnFarrell
P.S. Thinking outside the dots, a better example is:
- does this sequence of events occur in the PartialOrder given? This means that the output checking exists for a long time, and you have to be able to describe the partial order.
See also
JournallingPattern
moved here from UnitTests
In the last month I have been writing UnitTests for parts of my code, and I have to say that CheckOutputAutomatically is so much more effective that it should be compulsory.
The advantages are:
- automatic checks fail no matter what mood you are in - tired, drunk, indifferent
- if you get sick, your kids can run the UnitTests for you
- automatic checks can run while you are surfing the web
The disadvantages are:
- automatic tests are a bit harder to write, in fact as hard as the code was in the first place (but that makes the job more interesting)
- your boss and QA people can run UnitTests too This is an advantage - it means you can get back to writing code, instead of teaching them how to run the tests
I am a pretty good programmer, and pretty arrogant about how few bugs there
are in my code. When my
UnitTests started failing, I was pretty appalled at how talentless I was. Now that I have got the
UnitTests in, I can afford to be arrogant again :-). But I no longer claim that there are no bugs in my code when I haven't got a
UnitTest for it.
-- JohnFarrell
CategoryTesting