3

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?

GarethOwen
  • 6,075
  • 5
  • 39
  • 56

4 Answers4

2

Well, actually I had the same issue yesterday... At first I used this tip, but then I switched to the manuals :-)

A set of helper fixtures exist just to do that:

!|StringFixture|
|field|field?|
|some value|>>someSymbol|
|some other value|>>otherSymbol|

You can assign multiple symbols. And there are such fixtures for String, Int, Long, Float, Double, Decimal and Bool.

  • It seems a little convoluted to have to assign the value to the StringFixture Field, then read it out again in the next column into the symbol. However, it works and it's quicker than knocking up a custom fixture. Thanks. – Simon Elms Dec 01 '16 at 05:43
2

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.

Dan Woodward
  • 2,559
  • 1
  • 16
  • 19
0

To use the echo fixture I believe it needs to be imported via a library table first:

|Library     |
|echo fixture|

Then you should be able to use it like this:

//store a string using the echo fixture
|script                        |
|$myString=|echo|my string here|
Jason Slobotski
  • 1,386
  • 14
  • 18
0

You can also use the FitNesse wiki variable markup: http://fitnesse.org/FitNesse.UserGuide.FitNesseWiki.MarkupLanguageReference.MarkupVariables

!define SalesCubeID {1} !define ProductNodeID {3} !define DropTargetID {4}

|script | hierarchy | |selectNode; | ${SalesCubeID} | ${ProductNodeID} | |dropSelectedNode; | ${DropTargetID}|

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33