Setup Fitnesse for .NET Testing

November 12th, 2011
by Rod Claar

When new pilots are in training one of the most unnatural things to learn is the repeating back of instructions to the control tower or Air Traffic Control.  Sometimes these instructions are pretty complicated and the pilot has to write the instructions down and read them back.  Obviously the reason this is so critical is that the controller needs you to carry out his instructions and the first step in this is that you correctly heard these instructions.  But that is not all there is to it.  The pilot must understand these instructions to carry them out and maintain the safety of flight operations.  After the pilot hears, writes and repeats then the training tells the pilot check his understanding of the instructions.  If they are not understood the pilot must ask for a clarification and the whole process starts over again.  In this domain, the pilot generally understands the instructions because their preparation and training make most of these instructions routine.

As software developers, when we get our “instructions from ATC”, that is our requirements, they are often written rather than spoken. How well we understand those instructions depends on a number of factors starting with how well they were understood by the person writing them and their skill in putting them into words.  However a document does not have the built-in feedback loop that is required of pilots!  It is also very common for us to understand every word in the document, yet not have a clue what they are talking about or even worse think we understand perfectly when we really don’t have a clue.

Using the process of Acceptance Test Driven Development is one of the quickest and easiest ways to increase the pace and quality of business value delivery from your software development team.  Stating back our requirements to check understanding, while valuable, would be expensive and boring if all we did was create a new document and rewrite the requirements in more technical terms.  However if we could create this early validation that we understand the requirements in such a way as to be able to check the product’s progress toward meeting those requirements, then we might have something valuable and not so boring!

There are a number of tools being used to create Agile Acceptance Tests, but by far the most well known and popular is the FIT/Fitnesse family tools that allow you to create Agile Acceptance Tests for a number of different languages and platforms.

Introduction to Fit



Setting up Fitnesse requires a little history. FIT: Framework for Integrated Test was developed by Ward Cunningham and several collaborators.  I found pages on fit.c2.com from as early as 2001, so needless to say FIT has been around for quite a while.  In the introduction, Ward states that great software requires collaboration and communication.   FIT provided a basis for that two-way communication between the stakeholders and the team members.  Through the use of the various tables that were used to explicitly demonstrate the requirements, the team could create automated tests to check the current status of any requirement set up with these top-down tests.

While this is a great idea and a pretty good implementation, more was possible.  Bob Martin and his collaborators wrapped the FIT testing engine in a Wiki (which was a Ward Cunningham invention) and created FitNesse.

Here is how Wikipedia defines a Wiki:
A wiki (/ˈwɪki/ wik-ee) is a website that allows the creation and editing of any number of interlinked web pages via a web browser using a simplified markup language or a WYSIWYGtext editor. Wikis are typically powered by wiki software and are often used collaboratively by multiple users.

By wrapping the test engine in a Wiki, Martin and his collaborators enabled even more communication between the stakeholders and the development team.  Ideally the stakeholders would either record the requirements in the FitNesse Wiki and describe the scenarios with examples.

The original FIT was developed in Java.  Many developers added other platform implementations enabling the the use of FIT and FitNesse on the majority of application development projects.  This was a good thing, but there was a big problem.  Because of several factors including the desire to one-up other implementations, all of these implementations were different.  When I first started working with FIT, I downloaded it, installed it and then tried to use the included instructions to use the then current .NET implementation.  I tried for several hours!  After some searching, I found a nice article that discussed the setup for a .NET project.  This article was written by Gojko Adzic who remains a big contributor in the FIT/Fitness space.  My experience was typical and others spent days trying to get the FIT/Fitnesse port on their platform working.  The main problem was that all the implementations were different.  You could not always use what you learned on the Java implementations to set up the platform you were working on.

A few years later Martin and his team offered us an alternative to the FIT testing engine that makes this process much easier.  The Simple List Invocation Method is an alternative to FIT.  It is built into FitNesse.  Slim keeps the HTML processing, comparisons and the results output in FitNesse. In other words when you are using Slim, it does not call out to the FIT server to process the test results.  The big advantage is the fact that Slim is very slim.  It is easy to port because the calls to an external port are made with the same loosely coupled calls that are used with the internal Java implementation.  This allows all of the ports to be identical from an external API point of view.

Today FIT and FitNesse with Slim combined with the port for your platform provides a very powerful and capable set of tools to create and run top-down Agile Acceptance Tests.  FitNess and the .NET port of Slim and FIT are all in active development and you can use various online resources to get help and advice from other users and even the authors.

Setting up FitNesse

The place to start is the home of FitNess at http://fitnesse.org/.   Not too surprisingly this is a FitNesse implemenation.  It contains links to download the Java Jar file, Java source code and links to all known plugins and accessories.

FitNesse Plugins

First you need to downlaod the fitnesse.jar .  Save it to a convienet location on your computer.

A Java Jar file is just a zip file that contains the folders and files of the application.  It is roughly analogous to a .dll.  Fitness.jar is an executiable Jar file.  It is run by calling the Java runtime engine.   If you don’t have a Java runtime on your computer you will need to download the latest Java runtime engine from Java.com.

Next you need to decide where you want to put your FitNesse implemenation.  I like to keep my primary installation on the root drive of my computer.  I create a folder called FitNesse and copy the fitnesse.jar file there.

The next thing you need to decide is what port you are going to use for your FitNesse server.  Running the FitNesse.Jar file the first time unpacks the FitNessRoot which will be the repository of your wiki pages.  Then it starts the FitNesse server.

The command line looks like this…

java -jar fitnesse.jar

There are a number of optional command line switches, but the most important one is the -p which sets the port where the FitNesse server runs.  If you don’t use this switch it will try to run on port 80 where your web server probably runs.  It is a very good idea to include -p switch with an unused port like 8080.  So the full command line would be like this…

java -jar fitnesse.jar -p 8080

I don’t like to type that much, so I create a batch file to run the command put it in the fitnesse folder.  It would look something like this…

start java -java fitnesse.jar -p 8080

If all goes well you will get something like this is the command window that was opened by the batch file.

If the server does not start, take a look at the page on the fitness.org site http://fitnesse.org/FitNesse.UserGuide.FitNesseWontStart .

Then you can open your server with your favorite browser.

http://localhost:8080

Mine is going to look a bit different, but you should get the Fitnesse server.

Configuring FitSharp

At this point you have the base Java system up and running.  To enable .NET testing there is one more component and some configuration to do.

On the plugins page you may have noticed the .NET Slim implementation by Mike Stockdale.  It is located at https://github.com/jediwhale/fitsharp/downloads .  The site has both .NET 3.5 and 4.0 builds. Download the one that is approriate for your development environment.  The latest download has all the source and the entire binary history of the product.  Extract the files from the zip and copy the files from the latest binary into a folder on your system.  I put this folder in the fitnesse folder where you copied the Fitnesse.jar.  You can name this folder anything you want,but you will need to reference it in the next step.   I use dotnet2 with is a legacy name for me because of having tests set up from when support for .NET 2.0 was the latest.

When that is done, you are ready to go.  A future article will go into the details of how to use the system but for completeness on setup, there is one more step.

At the top level of a suite of tests ( or on any test page where the configuation is different ) we need to define four variables.  The first is the test system to be used.  This is how it would look in edit mode on the wiki for a slim test.

!define TEST_SYSTEM {slim}

Next is the command pattern which includes the full path to the fitsharp.dll.  Note  your path may be different.

!define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner, C:\Fitnesse\dotnet2\fitsharp.dll %p}

Next is the test runner.  Again your path may be different.

!define TEST_RUNNER {C:\Fitnesse\dotnet2\Runner.exe}

And last is the path to the .dll with the tests.  Put the full path and file name on the line.

!path

Here is what it looks like in edit mode…

And after you save, the page will look like this…

That’s all for now!  Watch for a new article every couple of weeks or so.  The next article will be an overview of the Slim tables and how to use a simple Decision Table.

Feel free to post messages with your questions so others can share in your experiences!

Tags: , , , ,
Posted in Agile Engineering Practices | Comments (1)

One Response to “Setup Fitnesse for .NET Testing”

  1. Mohan Says:

    Hi very nice article. When are you planning to give next article on Fitnesse

Leave a Reply

SEO Powered by Platinum SEO from Techblissonline