Geeks With Blogs
.net alternatives by Michel Grootjans

After my previous post, I've got a FitNesse server running and configured. It's now time to write some tests. Of course, since this is a demo, this will be a simple, self-explanatory test. I'll implement a simple calculator, capable of adding two integers.

Let's write that in FitNesse. First, I'll create a test suite called "DemoSuite". So I go to http://localhost:8888/DemoSuite. Since that page doesn't exist yet, FitNesse proposes a new page. I just accept it.

Then I go to a subpage, that I call http://localhost:8888/DemoSuite.CalculatorTest. Again, FitNesse doesn't recognize this page and proposes a new one. I now replace the content with this:

!1 Let's run a simple calculator

This gets rendered like this:


Notice what is expressed here: The test is a CalculatorRunner, that's what the top of the column says. Then I provide two arguments: Arg1=0 and Arg2=0. The Sum of both arguments should be 0. How do I tell FitNesse that the Sum should be checked? Simple: I've appended a "?" after Sum. That's enough to tell FitNesse that this is an assertion.

This test won't run of course. We now need to create a test fixture to accept the test. These are the steps to follow:

  • create a new project
  • add a reference to "fit.dll", located in the dotnet2 directory in the fit directory

There we create a new class that has to match exactly the name of our test. That will be "CalculatorRunner"

using fit;

namespace MyBlogPosts.FitNesse
public class CalculatorRunner : ColumnFixture
public int Arg1 { get; set; }
public int Arg2 { get; set; }

public int Sum()
return Arg1 + Arg2;

Get it? Each column in the FitNesse test above matches a property or a method in my testclass.

Ok, if I now run the test, it will still fail! Why? Because it can't find the assembly it's in. Lets fix that, shall we. Hit "edit" on the testpage (or navigate to http://localhost:8888/DemoSuite.CalculatorTest?edit)

Add the following on top of the page:

!path C:\...\bin\Debug\*.dll

This will tell FitNesse to scan that directory for assemblies too. It's kinda like having a reference in a project.

On last thing before you hit "Save" (you hit it already, didn't you?). Add the following too:


This is the namespace to import during this test. Kind of a "using" declaration in C#. Now run the test. Did it work? For me, this is the result:

image Looks OK to me. Lets expand the tests a little, shall we?

I'm editing the page like this:


Lets run it again:

image Oops, looks like I missed one... but hey. That's exactly what tests are for, no?

By the way, this is what a ColumnFixture in FitNesse is. Three more testtypes coming up, plus a little refactoring.

Posted on Tuesday, November 25, 2008 10:39 PM .net , FitNesse | Back to top

Comments on this post: My first FitNesse test

# re: My first FitNesse test
Requesting Gravatar...

I'm getting error after I put this line " !path C:\...\bin\Debug\*.dll"
at the top of the test.
I have a winform app for the calculator and it is located in "C:\Intellijet\WinFormTestFitness\WinFormTestFitness\bin\Debug"
and my exe is "WinformTestFitnesse.exe" so I have following code to generate my test :
!path C:\Intellijet\WinFormTestFitness\WinFormTestFitness\bin\Debug\*.dll
!1 Let's run a simple calculator

But when I hit "Save" button in (http://localhost:8080/DemoSuite.CalculatorTest) it gives me the following output with error :
classpath: C:\Intellijet\WinFormTestFitness\WinFormTestFitness\bin\Debug\*.dll


Let's run a simple calculator
Arg1 Arg2 Sum?
0 0 0

Please help ...

Left by IC on Oct 28, 2009 5:21 PM

# re: My first FitNesse test
Requesting Gravatar...
I'm not sure why you are getting that error. The example above states "!path C:\...\bin\Debug\*.dll" as an example. Don't take it literally. This should just be the path to the directory where your fixture assembly is located.

By the way, I recently gave up on absolute paths in fitnesse. I usually have a directory under the fitnesse root where I store the assemblies needed. So this !path directive now looks like this: !path /NameOfMyProject/*.dll
Left by Michel Grootjans on Oct 28, 2009 9:39 PM

# re: My first FitNesse test
Requesting Gravatar...
I am trying to use Fitnesse to display an excel table in my fitnesse page so for this i am copying the excel table and paste in edit page of Fitnesse and then click 'Spreadsheet to Fitnesse' button so it is converting it to table but the problem is improper formatting so if there any empty cells in my table or if a cell has alt+entered text it is considering it as a seperate row so i want this alt+entered text of a cell to be displayed in a single line just like how it is displayed in i need to display exactly the same excel table in fitnesse so is there anyway to do this without providing a link to excel table..??
Left by vtest on May 17, 2010 10:39 PM

Your comment:
 (will show your gravatar)

Copyright © Michel Grootjans | Powered by: