fixturesfitnessefitnesse-slim

Fitnesse assign value to global variable and reuse in multiple Fixtures


Hi I am new to Fitnesse framework, and I'm trying to find a way where I can assign a value to a global variable somehow from a database sequence. I already have written few test cases using a variable on page but its value had to be changed manually each time before running test, since I have declared it as,

!define prefix {100}

!|Some Col Fixuture-1
|header1  |header2        |
|Val1     |Val2-${prefix} |

!|Some Col Fixuture-2
|header1  |header2        |
|Val3     |Val4-${prefix} |

Is there any way I can assign value to variable "prefix" dynamically so instead of changing it manually I can just start test and at runtime it may get assigned to it. I tried assigning it in another fixutre before calling any other fixutre but that didn't work, I did something like below,

!define prefix {100}

!|Database Sequence Col Fixuture
|nextVal?  |
|$prefix = |

in java I have nextVal method and I'm calling DB to get next value from a sequence and it seems to be working but this new value doesn't get passed to other column fixtures mentioned above, probably due to scope of the variable.

It would be really great help if anyone can suggest or provide any sample to assign value to global variable and using it in multiple fixtures, or if there is any other way to do so. Any help would be really appreciated, thanks in advance.

Regards, Harsh


Solution

  • If you are using slim you should be able to use the variable as $prefix.

    Please note this is a different variable type, a slim symbol, as compared to the wiki variable you created using !define, you don’t need that define