Re: C++ fluency
On May 6, 4:51 pm, Jerry Coffin <jcof...@taeus.com> wrote:
In article <76d32lF1c73b...@mid.individual.net>,
[ ... ]
If you use TDD, the tests always fail first time. You add
the code to make them pass.
This makes me curious. Why would you bother running the tests
if you _know_ they're going to fail?
To be sure that they do fail if the code is broken. It's
standard proceedure for regression tests---when you get an error
report from the field, you don't correct the code until you have
a regression test (a unit test) which detects the error (fails).
This doesn't really apply to your initial code, however; the
fact that the test fails if there is no code doesn't prove
anything about whether it tests what it is actually supposed to
test. For the initial code, you need code review, which
includes reviewing the tests for completeness.
I've always written the tests first, but then written at least
some minimal bit of code that should pass at least some part
of the tests before attempting to run the tests. What's the
point of running the test when you're sure there's no
possibility of even coming close to passing it at all?
Testing the test? If the test is supposed to test something
very specific and non-trivial, it might be worth creating a
special version of the code to be tested, with the exact error
the test is meant to reveal. This is very important with parts
of the test framework: when I wrote my memory checker, for
example, I intentionally wrote code which leaked memory, to
ensure that the leak was detected. For most of the traditional
unit tests, writing such special code is probably not worth the
effort, but when you have an actual failure, which doesn't show
up in your tests, it's certainly worthwhile making sure that the
test you add detect it befoer correcting the error.
James Kanze (GABI Software) email:firstname.lastname@example.org
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34