[CCd to testfirstuserinterfaces@yahoogroups.com ]
Baris Evrim Demiröz wrote:
> From the first time I saw XP I thought it is a very good methodology.
> But I have a questions about unit testing.
> As you may already know, in image processing most of the things work
> with a probability. Let's say you have a method that finds the
> location of faces in a given image, and this algorithm works well 98%
> of the time, and gives false trues (a location that doesn't contain
> any face). How do you test such a method?
Study the source to Cairo (part of Gtk+). It uses a system called "golden master
test". Each test case (at this level) draws a little graphic, such as one
diagonal line. Then the test case byte-compares the image to a png file.
If the test output is right and the png file is wrong, engineers replace the png
file with the new output. That's why the master files are "golden" - they are
part of your versioned source.
This system won't prove you match faces. TDD cannot test that crypto makes your
app bulletproof, or that compression absolutely minimizes your files, or that a
Turing loop will never halt.
This system should stop you if you make a change too big for its tolerances.
This frees your edits up to make whatever change you like. Get a battery of
known faces, and test that they all get recognized to within their expected
variations.
When you actually TDD, you are simply matching tests to low-level code, to check
it manipulates its bits correctly. Most of your tests should run below the level
of the faces.
--
Phlip