Search code examples
fitnesse

Same instance of fitnesse fixture for each script tag


I am new to fitnesse and I am writing a fitnesse script and for some requirement, I have the following scenario:

|script|fixture1|
|check|do something1|ok|

|script|fixture2|
|check|do something fixtur2|ok|

Then something else with same fixture1:

|script|fixture1|
|check|do something else|ok|

In the above scenario, two instances of fixture1 will be created but I want to avoid that and want to use same object as created in part of first script tag.

Is there any way to re-use the same object?


Solution

  • You could define both fixture 1 and 2 as libraries, and then use script tables that do not specify a fixture class (ie first row with only script cell)

    Or you could (if only fixture 1 instance should be reused) remove the fixture 2 cell from the second table's first row, and add a second row to it containg a cell push fixture, a third row |start|fixture 2| and a last row pop fixture. The third table's first row must finally be changed to justscript. This will make the third table use the same fixture 1 instance as table 1.