.netfitnessefitsharp

How to set symbol with a constant value in FitNesse using FitSharp


I want my FitNesse test setup code to look like something like this, to simulate a drag and drop interaction on a hierarchy menu:

$SalesCubeID = 1
$ProductNodeID = 3
$DropTargetID = 4

|script            | hierarchy |
|selectNode;       | SalesCubeID | ProductNodeID |
|dropSelectedNode; | DropTargetID|

It all works when I hard code the values into the table, but I would like to use symbols to improve the readability. But I can't work out how to set the Symbol values like this.

I have seen other code using an 'echo' fixture to set the values in a script table like this:

|script       | echo fixture |
|$SalesCubeID=|echo|1|

but I get the exception:

Method echo not found in fitSharp.Slim.Operators.InvokeInstructionBase+NullInstance

What do I have to do to use the echoFixture in FitSharp? Or is there another way of setting symbols to constant values?


Solution

  • You need to write you own fixture to do this. Echo is in the Java code and not accessible to a fitSharp test.

    It doesn't have to be too fancy.

    public class Define
    {
    
       public string define(string value)
            {
                return value;
            }
        }
    }
    

    Then add this to your .Net assembly path.

    Finally, in your test page add the following table:

    |Library|
    |Define|
    

    Then you should be able to use the define method in your tests. We called it Define, but you could call it echo. It's the same thing either way. The key thing is having a method that returns what you give it.