Simple Fitnesse Example

While I like the Fitnesse example built into the wiki, I really can’t get a feel for it until I hook the test fixtures into some of my own code. Stepwise:

  1. Download Fitnesse.
  2. Launch the run.bat or run.sh script to launch the Fitnesse web server on port 80.
  3. On the front page click on Edit.
  4. Copy the format for the Fitnesse.SuiteAcceptenceTests on a new line. In this case for Example Acceptence Tests. Click Save.
  5. Click on the link for the new page and add the following code:
!path /edgibbs/example_project/build/classes

!|com.edgibbs.fitexample.PersonFixtureTest|
|firstName|checkFirstName?|
|Harry |Harry    |
|Irga | Irga     |
|null | null |

The path setting should point to the area where the classes are built. The firstName will set the firstName property, and the checkFirstName will return a String for the firstName from the fixture class.

  1. Run test, it should fail because class won’t exist.
  2. Create following class to test an overly simple javabean, Person. Person just has a firstName String property with getters/setters:
package com.edgibbs.fitexample;

import fit.ColumnFixture;

public class PersonFixtureTest extends ColumnFixture {
  private Person person = new Person();
  public String firstName;

  public String checkFirstName() {
    person.setFirstName(this.firstName);
    return person.getFirstName();
  }
}
  1. Compile the class.
  2. Run the Test again. You should get green rows, yeah! And yes, this example is pretty trivial, but I like to start small.