Search code examples
c#fitnessefitsharp

Fitsharp, how to give symbols as argument?


I'm using FitNesse with FitSharp (.Net), and I'm trying to Setup a test suite :

  1. Generate a random port
  2. Setup execution path
  3. Start process on port, in path, and retreive it's pid

My C# code looks like this:

public int RandomPort() {...}
public int SetupWebsite() {...}
public int StartWebsite(string path, int port) {...}

My Fitnesse looks like this:

!|Setup|
|RandomPort?|
|>>port|

!|Setup|
|SetupWebsite?|
|>>path|

!|Setup|
|StartWebsite?|<<path|<<port|
|>>pid|

The error : fitSharp.Machine.Exception.MemberMissingException: Member 'startwebsite' with 0 parameter(s) not found for type 'Web.Api.Tests.Setup'.

I've try many things, but it never works, the problem is not that i'm doing something wrong (wich is obvious), but I can't find how to do it right...

I'm really having a hard time with Fitnesse... I can't find anywhere and up-to-date tutorial, or any ressources to help me creating a nice SuiteTest... To add more context on my question, I want to start an IISExpress (my Setup) on a Web.Api 2 project, And then make some Json/Rest calls on it, my Teardown should simply kill the IISExpress process, and clear the tempory website folder.

Thanks for help !


Solution

  • The symbol save operator (>>) and the symbol recall operator (<<) can be used to collect a value at one place in a story test and then use it in other places. The symbol save operator can be used in any expected value cell. Instead of comparing the actual value to an expected value, the actual value is saved with the symbol name.

    You can use the check keyword:

    !|setup|
    |check|randomport|>>port|
    |check|setupwebsite|>>path|
    |check|startwebsite|<<path||<<port|>>pid|
    

    See http://fitsharp.github.io/Fit/SymbolValues.html

    You can also use the name keyword. The name keyword assigns an object to a symbol name, which can be used to retrieve the object later.

    !|setup|
    |name|port|randomport|
    |name|path|setupwebsite|
    |name|pid|startwebsite|<<path||<<port|
    

    See http://fitsharp.github.io/Fit/NameKeyword.html

    Note that in a method call, the method name is made by concatenating every other cell. The other alternating cells are input values.