March 20, 2007 - Characterization Test Failures

For completeness, I run the characterization tests one last time. As you might expect, there are failures because the behavior of getSecondBall() and needsMoreBalls changed.

This test...

    public void testGetSecondBall() throws Throwable {
        Frame frame = new Frame(new Frame(new Frame(new Frame(new Frame(null, true), false), true), false), false);
        String result = frame.getSecondBall();
        assertEquals("result", "1", result);

...failed with...

junit.framework.ComparisonFailure: result expected:[1] but was:[/]

And this test....

    public void testNeedsMoreBalls3() throws Throwable {
        Frame frame = new Frame(null, true);
        boolean result = frame.needsMoreBalls();
        assertFalse("result", result);

...failed because a spare now needs a bonus ball.

The tests failed because the behavior changed - which is exactly what you want characterization tests to do. It shows they are doing their job. In this case the failures were expected because I did not introduce any regressions. As a test-infected TDDer, I already had comprehensive tests - the non-test-infected among us would get much more benefit - but even TDDers tend to focus on the happy path. JUnit Factory really earns its keep on those unexpected outcomes that you thought could not happen.

I regenerated the tests one last time and linked them so you can see you how they look. Quite impressive, I am sure you will agree.

Posted by Kevin Lawrence at March 20, 2007 07:27 PM

Trackback Pings

TrackBack URL for this entry:


Post a comment

Remember Me?