Say we wanted to test division to see if it is acceptable. (We normally test more complicated things, things that we can control, but this is a simple example.)

We will make two things to complete our test. The first is a description of what we want including a tabular list of test cases that we believe will show that division is working acceptably.


Part 1 -- The Specification

We want division that works with positive and negative numbers.

eg.Division
numerator denominator quotient()  
1000 10 100.0000  
-1000 10 -100.0000  
1000 7 142.85715 For this one to succeed, I had to add a charBounds attribute to the fixture.
1000 7 142.85714 And this one succeeds - it's close enough.
1000 .00001 100000000  
4195835 3145729 1.3338196 This is the infamous Pentium bug.

This last case is the famous pentium bug. See http://www.cs.earlham.edu/~dusko/cs63/fdiv.html.


The second thing we make is a "fixture" that can take the data provided in the table and compute the expected results. The fixture is a java program that can perform the operations that we want to test.


Part 2 -- The Fixture

  public class Division extends ColumnFixture {
    public float numerator;
    public float denominator;
    public float quotient() {
      return numerator / denominator;
    }
  }


Our two parts, the specification and the fixture, are connected by the fact that the table names the fixture (Division) in its first cell. The Division fixture knows how to make sense of the table because it extends a class that already does. A column fixture looks for variables and methods it might have that match the column headings in the table.

After we've prepared these two parts and put them into appropriate files, we run the test to produce results, a copy of our input with right and wrong answers noted.