The "negative" tests seem to be a variation or a special
instance of the Triangulate pattern. I guess I have to give an
example.
The example is how CanooWebTest does selftesting by applying it to
itself. What we have to test is, that our verification of web pages
works as expected.
From
follow the link to "Latest Results of Functional SelfTest". That is
the test report (created by the CruiseControl).
Test No 4 makes a good example for trying to invoke a page and verify
it somehow. Then a *negative* test follows to show how verification
is expected to fail. (It is wrapped in a NOT, which is like
assertFalse() in unit tests)
The special thing here is, that positive and negative tests are not
redundant as opposed to the example about Triangulation.
The FITYMI impl of page verification can just return true as long as
you have the positive test only. The negative test finally enforces
the logic.
I experienced quite a nice effect with this: there is (almost) always
one test breaking and the other working until I'm finished. The
information of which on is currently breaking gives good guidance
while proceeding from FITYMI to full implementation. Really good
honest feedback without trying to fool myself. When tests are green,
I'm _really_ finished.
BTW: I don't fully understand the word "Triangulation" maybe because
it has no one-to-one translation into german. Is it that the
two asserts and the production code make up a triangle?
What am I supposed to do with that triangle? Calculate the
third point (production code) by knowing the remaing two?
Then I need some more information (lengths, circumference, angles...)
I need some more guidance to understand the anology.
cheers
Mittie
"Lately we used "negative tests" to drive the code from
constants to calculation.
starting with an assert and a constant implementation
we write a second assert that shows how the code is
expected to fail.
---
Please tell me if this is covered in the Triangulate pattern. I've
done
this, too, but it drives me nuts. This could easily be a flaw in my
technique.
---