That way, you can program like a monkey until the unit tests pass.
This is my blog about software development, mountain unicycling, Photography, and stuff I find interesting.
That way, you can program like a monkey until the unit tests pass.
Posted by Chris Bensen at 7:00 AM
10 comments:
So do you feel like a monkey lately?
You make that sound like it's a bad thing?
If you put a million monkeys at a million keyboards, one of them will eventually write a Delphi program.
The rest of them will write Perl programs.
How can you tell, looking at a unit test if it is a useful unit test? One that will some day perhaps catch a regression? Hmm. I find that most unit tests I can think up are either (a) pointless, will never fail, (b) do not cover even 0.001% of the decision points or branches in a major function, and are thus shallow and (c) are often things that if I want to fix point (a) and (b) will become 500+ line behemoth unit tests.
:-)
W
Warren,
Like anything it really depends. There are always tradeoffs. First you have the tradeoff between writing a more badass program vs increasing the quality. Unit tests take time but in the long run will pay off dividends especially when paired with continuous integration with something like Cruise Control or Hudson.
If your functions are so large that they can't be tested consider breaking them up into smaller more testable functions. That will reduce the branches and allow you to create a table of all the cases. The cases may still be huge, but you really care about boundary conditions. Consider a function with the following prototype:
function Foo(Value: Integer): Boolean;
What boundary conditions would you use?
Experience shows that the most useful unit tests emerge from former bug reports :)
"That way, you can program like a monkey until the unit tests pass."
Guess that explain a lot about Delphi lately
mb, Yes, bug reports turned into unit tests are great sources of tests. They allow an incremental addition testing a boundary case and they exercise a real world use.
LDS, if you mean the consistency of quality has gone way up then you are spot on! I wish I could shed some light on how we are using continuous integration around here and how many tests get run every day, on every checkin, every build, every OS permutation, etc, etc.
Since nobody else has said it yet:
Code Monkey get up, get coffee,
Code Monkey go to job...
Post a Comment