After a day of getting FIT I was able to run the FitNesse wiki and poke around a bit and run some more acceptance tests.  This I found very interesting and quite impressive really.  It was truly simple.  So how do I write acceptance tests for my .NET applications.

The first step is understanding how a java based FitNesse wiki ran my .NET acceptance suites.  Fortunately this was pretty easy.  Under the fitnesse install directory their is a subdirectory called dotnet.  It the dotnet directory there is a .NET implementation of the FitServer that consumes test tables and communicates back results.  All we have to do in our wiki pages to tell FitNesse to use the .NET FitServer instead of the Java one to run our acception tests.  This is done by placing the following at the top of the wiki page that you write the acceptance test in:

!define COMMAND_PATTERN {%m %p}
!define TEST_RUNNER {dotnet\FitServer.exe}
!define PATH_SEPARATOR {;}
!path dotnet\*.dll

That’s it.  Then add the following test table to your page as well

!|eg.ArithmeticColumnFixture|
|x|y|plus()|
|10 |2 |12 |
|12 |3 |15 |
|100 |4 |104 |

The syntax is simple enough. 

  • Line 1:  The test fixture to run, with eg.ArithmeticColumnFixture being a fully qualified class name 
  • Line 2:  These are public members on the test fixture in first two columns, and the final column is the method that is called to perform the test.
  • Line 3-5: These values are assigned to the test fixture members and  the plus() called.

 

 

 

This page shows an example test table as it is rendered within the FitNesse.  Notice how FitNesse displays the .NET settings of the page.

To run the test, click the Test button that is in top left hand corner of the menu items.  (Note that to make a page a Test, select properties from the menu items and choose the Test option box.)

 

 

 

 

 

After you run the test, the results are displayed.

 

 

 

 

 

 

This works okay, now how do you write you own.  Take the following steps:

  • Open your VS Studio Project with the code that you want to test.
  • Write your acceptance test fixture code
  • Have your project *.dlls copied into the FitNesse/dotnet directory (Post Build Events in VStudio are good for this).
  • Write you test table wiki page and run.

 

One thing to note.  I was build using VS Studio 2005 and FitNesse was having problems finding classes within my assembly files.  To fix this I had to checkout the latest FitNesse.DotNet from the trunk and build it (You need NAnt). 

 

Once done, I copied the required binaries into the FitNesse\dotnet directory and everything worked fine.