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:
- Download Fitnesse.
- Launch the run.bat or run.sh script to launch the Fitnesse web server on port 80.
- On the front page click on Edit.
- Copy the format for the Fitnesse.SuiteAcceptenceTests on a new line. In this case for Example Acceptence Tests. Click Save.
- 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.
- Run test, it should fail because class won’t exist.
- 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(); } }
- Compile the class.
- Run the Test again. You should get green rows, yeah! And yes, this example is pretty trivial, but I like to start small.