*update - 2008/12/23* Most of the problems this article describes have now been resolved with the latest release of Fitnesse (which finally includes a working version of the .NET fitlibrary). Ignore the Installing Fitnesse section, but the Running Fitnesse as a Service steps still apply.
If you’re anything like me, you like to find a solution that works the first time without a lot of hassle. Unfortunately, Fitnesse with the .NET 2.0 framework was neither. Here’s a step-by-step guide to avoiding the many pitfalls along the path to test enlightenment.
Installing Fitnesse
- Download the 06/2007 release of Fitnesse.
- Unzip the archive. Note the dotnet folder will be empty.
- Edit the fitnesse\run.bat file to include -p 8080 if IIS is running on the same server:java -cp fitnesse.jar fitnesse.FitNesse -p 8080 %1 %2 %3 %4 %5pause
- Download the .NET fit library.
- Unzip the archive to the dotnet folder of fitnesse (e.g., c:\fitnesse\dotnet).
- Double-click the run.bat file (e.g., c:\fitnesse\run.bat).
- A command window will open with the following:>java -cp fitnesse.jar fitnesse.FitNesse -p 8080FitNesse (20070619) Started…port: 8080root page: fitnesse.wiki.FileSystemPage at ./FitNesseRootlogger: noneauthenticator: fitnesse.authentication.PromiscuousAuthenticatorhtml page factory: fitnesse.html.HtmlPageFactorypage version expiration set to 14 days.
- If you see something like the following, you need to install Java:‘java’ is not recognized as an internal or external command, operable program or batch file.
- Fire up your favorite browser, and enter http://localhost:8080/FrontPage. This will take you to the main fitnesse page.
- Start editing.
- If you want to be able to edit the main page, browse to http://localhost:8080/FrontPage?properties and select the Edit checkbox, then click the Save Properties button.
- Otherwise, enter a new page name (e.g., http://localhost:8080/MyNewTest). This will ask you if you want to create a new page.
- Whichever path you choose on the previous step, go into the edit page and enter the following:
!***> root config
!define COMMAND_PATTERN {%m %p}
!define TEST_RUNNER {dotnet\FitServer.exe}
!define PATH_SEPARATOR {;}
***! - Make sure your fixture projects reference fit and FitLibrary (though you’ll refer to FitLibrary as fitlibrary in code) in the fitness\dotnet folder if you want to use DoFixtures.
Make sure you set the Fit reference to copy local=false. This will prevent hours of lost productivity trying to figure out what the heck "Couldn't cast YourFixtureNameHere to Fixture. Did you remember to extend Fixture" errors mean. - Edit each test page (alternatively, you can just add this to a root page — it will be inherited by all child pages) with:
!path path_to_your_test_fixture_dll
That’s it! You’re on your way to creating tests with Fitnesse and the 2.0 framework.
Get the Windows Resource Kit.
Install the Windows 2003 Resource Kit. You will only need the instsrv.exe and srvany.exe programs. So you can copy those out and deinstall the kit if you don't want it around.
Use the instsrv.exe program to install the srvany.exe program by using it like this from the command-line:
instsrv.exe FitNesse "\srvany.exe" -a MYMACHINE\fitnesse -p soSecret Run the regedit.exe program to set the last parameters.
Find the key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet[?]\Services\FitNesse
Create a subkey with the name Parameters
In the parameters key, create a string value called Application and set its value to the full path of the java.exe file. For me it was : C:\Program Files\Java\jre1.5.0_04\bin\java.exe.
Create another string value called AppDirectory and set its value to the path where you want the executable to run. The directory where your FitNesse files are located : c:\Program Files\FitNesse
Create a last string value called AppParameters containing the parameters passed to the java executable above : -cp fitnesse.jar -Xrs fitnesse.FitNesse -p 8080
Open the service control panel and start the service.
You can now write the same fixtures and reference them from Fit or Fitnesse. I hope you find these instructions helpful. Happy testing.
-David