Saturday, July 9, 2011

Starting a FitNesse project with fitSharp

FitNesse and fitSharp offer so much flexibility that there's many different ways to configure a project, but for the beginner, a common question is: OK, but where do I start? So here's how I set up a sample project.

I got fitnesse.jar from http://fitnesse.org and put it in C:\apps\fitnesse. I got the latest fitSharp release from http://github.com/jediwhale/fitsharp and unzipped it into c:\apps\fitnesse\dotnet.

I created a Visual Studio solution in c:\projects\fitsharpsample.  I added a class library  project called Fixtures.  I added references to fit.dll and fitsharp.dll from c:\apps\fitnesse\dotnet.  I added a class called SampleDo:
using fitlibrary;

namespace Fixtures {
    public class SampleDo: DoFixture {
        public string Greeting { get { return "hi"; } }
    }
}
In my solution folder, I created a fitnesseRoot folder. I created a file fitnesse.cmd to run FitNesse:
java -jar \apps\fitnesse\fitnesse.jar -p 8080 -d "c:\projects\fitsharpsample" -r fitNesseRoot
pause
I created a configuration file storytest.config.xml:
<suiteConfig>
    <Settings>
        <Runner>fitnesse.fitserver.FitServer</Runner>
    </Settings>

    <ApplicationUnderTest>
        <addNamespace>Fixtures</addNamespace>
        <addAssembly>c:\projects\fitsharpsample\build\debug\Fixtures.dll</addAssembly>
    </ApplicationUnderTest>
</suiteConfig>
In my browser, I went to http://localhost:8080 and clicked the root link and edited the root page to contain:
!define TEST_RUNNER {c:\apps\fitnesse\dotnet\Runner.exe}
!define COMMAND_PATTERN {%m -c c:\projects\fitsharpsample\storytest.config.xml %p}
 I added a SampleTest page in FitNesse:
|sample do|
|check|greeting|hi|
I ran the test and all green!

Assertions: 1 right, 0 wrong, 0 ignored, 0 exceptions (0.000 seconds)
sample do
check greeting hi

0 comments:

Post a Comment