Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

step by step tutorial for using slim fitnesse in .net

anybody knows some step by step tutorial for using slim fitnesse in .net ?

for now I managed to run the slim fitnesse website on my localhost:3434

and I unziped the fitSharp plugin in c:/fitSharp

but I have no idea what's next

like image 326
Omu Avatar asked Jun 02 '11 13:06

Omu


People also ask

How do you use the FitNesse tool?

To open FitNesse, open your browser and type: http://localhost:<portnumber>. In this case, the port number is 2222. So here, if you can see the Tests dropdown, we can create a “Suite page” as well as a “Test Page”. When you create a suite, all the test scripts within that suite will be executed.

What is the syntax to slim test runner?

If you want a test page to be run under SLIM, you simply set the TEST_SYSTEM variable to "slim" instead of "fit". If this variable is set on your page, (as it is on this page!) or on any parent page, then your page will be run with Slim.

What does SLIM stands for in FitNesse?

Slim (Simple List Invocation Method) is an alternative to Fit. Rather than running all the HTML processing, comparisons, and colorizing in the System Under Test (SUT), Slim keeps all that behavior on in FitNesse.


1 Answers

FitNesse is a wiki with tables that can be executed to do system testing. Tables will then tell FitNesse to create some classes, do some operations on them, and check the result.

In order to work with .NET for example, you simply need to tell FitNesse how to link with .NET and which .NET assemblies to load. Nothing else. The .NET project can be a simple class library with no knowledge of FitNesse at all.

Requires tools

  • FitNesse - The Java-based FitNesse wiki and testing framework.
  • fitSharp - Contains .NET libraries to write FIT and SliM fixtures.

Sample steps

  1. Download FitNesse and fitSharp (in this example fitSharp has been extracted to D:\fit\fitSharp\release.1.9.net.35\)

  2. Start FitNesse from the command-line:

    java -jar fitnesse.jar -p 8080
    
  3. Create and compile a C# Class Library project with:

    namespace ClassLibrary1
    {
        public class ShouldIBuyMilk
        {
            private int _cash;
            private int _pintsOfMilkRemaining;
            private string _useCreditCard;
    
            public void SetCashInWallet(int cash)
            {
                _cash = cash;
            }
    
            public void SetCreditCard(string useCreditCard)
            {
                _useCreditCard = useCreditCard;
            }
    
            public void SetPintsOfMilkRemaining(int pints)
            {
                _pintsOfMilkRemaining = pints;
            }
    
            public string GoToStore()
            {
                if (_cash > 0 || _useCreditCard.Equals("yes"))
                    return "yes";
                return "no";
            }
        }
    }
    
  4. Browse to http://localhost:8080/ then click '[add child]' next to the title and add a 'Test' page.

  5. Type in the wiki page content like below (update the paths):

    !define TEST_SYSTEM {slim}
    !define COMMAND_PATTERN {%m -r fitSharp.Slim.Service.Runner,D:\fit\fitSharp\release.1.9.net.35\fitsharp.dll %p}
    !define TEST_RUNNER {D:\fit\fitSharp\release.1.9.net.35\Runner.exe}
    
    !path D:\fit\MyFixture\ClassLibrary1\bin\Debug\ClassLibrary1.dll
    
    !|import|
    |ClassLibrary1|
    
    |Should I buy milk|
    |cash in wallet|credit card|pints of milk remaining|go to store?|
    |      0       |    no     |      0                |    no      |
    |      10      |    no     |      0                |    yes     |
    |      0       |    yes    |      0                |    yes     |
    |      10      |    yes    |      0                |    yes     |
    |      0       |    no     |      1                |    no      |
    

    Note the '!' before !|import| is to avoid 'ClassLibrary1' to be seen as a wikiword.

  6. Save it, and click "Test" in the left menu.     FitNesse will load the assembly, create an instance of your class, set some properties by following the naming convention mapping, and finally check some properties.

    See also

    • http://schuchert.wikispaces.com/Acceptance+Testing.UsingSlimDotNetInFitNesse
like image 152
Wernight Avatar answered Nov 06 '22 16:11

Wernight