• Jobs
  • About
  • Getting Started with FitNesse February 8, 2009

    This article covers:

    • Downloading and setting up FitNesse
    • Writing your first Hello World fixture
    • Writing your first test case using this fixture and running it.

    Downloading and setting up FitNesse

    As mentioned in the Introduction to FitNesse post, FitNesse is a great tool to build frameworks on. This section covers how to setup FitNesse. The assumption here is that you have an environment setup similar to the one defined in the Creating your Java project workspace post.

    At the time of this update to the post, the latest release of FitNesse is Release 20100103. Follow these steps to add FitNesse to your environment.

    1. Download fitnesse.jar to your projects lib directory (testautomation/lib).
    2. Download fitlibrary from its sourceforge. Once you unzip the downloaded file, fint the fitlibrary.jar under FitLibrary20091020/fitnesse/fitlibrary.jar and place it in your lib directory.
    3. Now run the java command:
      java -jar lib/fitnesse.jar -p 8080 -r fitnesse
      This will unpack files essential for running fitnesse and then start up the fitnesse server with the fitnesse root directory as testautomation/fitnesse.
    4. As part of the unpacking in the previous step, we now have all the js, css, gif etc files needed to serve the wiki pages. You should now be able to access this fitnesse wiki by opening http://localhost:8080 in your browser.

    You can tell if the setup was successful if you see a screen saying:

    Welcome to FitNesse!

    There is an easier way to start and stop fitnesse each time. Just add the following properties and ant targets to your build.xml file:

    <property name="fitnesse.root" value="fitnesse"/>
    <property name="fitnesse.port" value="8080"/>
    <target name="start-fitnesse" description="spawns fitnesse server">
    <echo message="Starting FitNesse on port ${fitnesse.port}" />
    <java classname="fitnesseMain.FitNesseMain"
    <arg line="-p ${fitnesse.port} -r ${fitnesse.root}"/>
    <sysproperty key="COMMAND_PATTERN" value="java -Xms32M -Xmx192M -cp %p %m"/>
    <target name="stop-fitnesse" description="stops fitnesse server">
    <echo message="Stopping FitNesse running on port ${fitnesse.port}" />
    <java classname="fitnesse.Shutdown"
    <arg line="-p ${fitnesse.port}"/>

    Now you can start fitnesse using the command:
    ant start-fitnesse
    and stop it using:
    ant stop-fitnesse

    Setting up your Sandbox

    Lets now create a sandbox area that we can use for trying out the different capabilities of FitNesse.

    Create a link to get to your SandBox

    Bring up your browser window again by going to http://localhost:8080. Click the “Edit” link in the left panel of the page. Change the content of the page to:

    !c !3 Welcome to the Wonderful World of !-FitNesse-!!
    |Table of Contents|
    |SandBox|This is the place where you can experiment with !-FitNesse-!|

    Create your SandBox wikipage

    You will now see a [?] next to your SandBox text. This is how FitNesse’s wiki engine detects a wiki word prompting you to make a new wiki page that will be named SandBox. Once you click the question mark, you will see a new page with a textarea with text:
    !contents -R2 -g -p -f -h
    Click the Save button. This will create your Sandbox wikipage.

    Your first Fixture

    There isn’t a whole lot you can do in fitnesse at this point. It starts getting interesting once you start developing your fixtures. A Fixture is a class that FitNesse uses to find and run the actions associated with the steps of your test case.
    Let’s now see how to create our first Fixture in java. In this example we will demonstrate FitNesse’s capability to reflect upon a java class and call the method for the instruction in our test case.

    Creating a Greet The World Fixture

    Create a new GreetTheWorldFixture.java file in the package of your choosing. For this example we have used net.qaautomation.fitnesse.fixtures package.

    package net.qaautomation.fitnesse.fixtures;
    import fitlibrary.DoFixture;
    * Hello World example of a FitNesse fixture.
    * @author Rahul Poonekar
    public class GreetTheWorldFixture extends DoFixture {
    public String sayHi() {
    return "Hello World";

    Compiling your Fixture

    If you have set up your environment as described in the Creating your Java project workspace post, all you have to do is to run
    ant build
    in your testautomation project folder. If you have a different environment layout, you can simply run the javac command with fitnesse.jar in your classpath.

    Your first test case

    Now that you have created your fixture, let us now call it from our test case. To create your HelloWorld test case in your sandbox follow these steps:

    • Open your browser and go to http://localhost:8080
    • Click on the SandBox link.
    • Now click the Edit link.
    • Under the !contents ... line add another line
    • Click Save button. You will now see HelloWorld[?] in your SandBox page.
    • Click the ? link to create a new wiki page.
    • For the contents of the page enter the following lines (if there were any other lines that showed up by default, you should remove them):
    • !define TEST_RUNNER (fitlibrary.suite.FitLibraryServer)
      !path lib/fitlibrary.jar
      !path lib/fitnesse.jar
      !path build/testautomation.jar
      |show|say hi|
    • Click on the Save button
    • Now click on the Properties link.
    • Here select the Test choice and then the Save Properties button.
    • Its finally time! Click the Test button.

    You should see the following output:

    FitNesse Hello World test execution screenshot

    Notice the output Hello World – which was returned by the GreetTheWorldFixture.sayHi() method call!

    This concludes the discussion around how to get started with FitNesse. Hopefully you now have a working setup for FitNesse that you can use for adding capabilities for testing the functional components of your application.

    More Information and Resources

    Posted by Rahul Poonekar in : FitNesse

    5 responses to “Getting Started with FitNesse”

    1. Srini says:

      Glad to see updates on this.
      As always your passion for quality to encourage & educate user community.

      One recommendation, Please index your pages with Google + other search engines, this way it would be visible to user community while searching on FitNesse.


    2. Samantha says:


      Can you please explain setup and teardown methods in FitNesse and how to use them effectively?

      Thanks in Advance!!


    3. Gowtham says:

      WOW….really descriptive post..Thanks a lot

    4. Karina says:

      This doesn’t work.
      I followed this step by step and it fails when I try to run the test. First of all, I cannot compile fitnesse.jar without compiling fitlibrary.jar as well.

      javac -cp fitlibrary.jar:fitnesse.jar greet/GreetTheWorldFixture.java will compile it,
      but when running the test, I get

      Assertions: 0 right, 0 wrong, 0 ignored, 2 exceptions (0.004 seconds)
      variable defined: TEST_RUNNER=fitlibrary.suite.FitLibraryServer

      classpath: fitlibrary.jar
      classpath: fitnesse.jar
      classpath: greet/greetFixture.jar

      Assertions: 0 right, 0 wrong, 0 ignored, 2 exceptions (0.006 seconds)
      variable defined: TEST_RUNNER=fitlibrary.suite.FitLibraryServer

      classpath: fitlibrary.jar
      classpath: fitnesse.jar
      classpath: greet/greetFixture.jar

      greet.GreetTheWorldFixture Missing class or Missing method. Possibly:

      public Type getGreetDotGreetTheWorldFixture() { }
      public Type greetDotGreetTheWorldFixture() { }


      Missing method, possibly:
      public Type getSayHi() { } say hi
      public Type sayHi() { }


    5. Rahul Poonekar says:

      You are right in that you need both fitnesse and fitlibrary jars in your classpath to compile your code. I did that by using ant.

      As for the error you are getting while running your test, it doesn’t seem like your jar containing the Fixture (greetFixture.jar) is in the classpath. I would double check that you have added it in the COMMAND_PATTERN, the path to the jar (greet/greetFixture.jar?) is correct and that the package you created for the Fixture (greet.GreetTheWorldFixture) is correct.

    Leave a Reply

    Your email address will not be published. Required fields are marked *