Search code examples
testingfitnesse

Using let created variables in other fitnesse fixtures


I have a problem with using let created variables. I'm using RestFixture to get/post from http location and I do want to use this answer in another fixture:

  1. I'm getting data via post
  2. saving body as variable using let
  3. printing my variable in comment line to see that is really working

|!-CustomRestFixture-!|http://addres |CONFIG|
|setHeader |Content-Type : application/json |
|setBody | {some JSON body} |
|POST | |200 |Content-Type: text/plain | |
|let |myvariable |body|//* | |
|comment | This is my variable : %myvariable% |

  1. Then I would like to use it in another (custom made) fixture that compares two strings (second fixture is inside same test page) :

!|DecTable|
|my first value|my second value|is this equal?|
|aaa |aaa |true |
|%myvariable% |anything |ture |

  1. What I can noticed is my variable is not working anywhere else that in RestFixture. I can not pass is any further, but it suppose to be global

Is there any solution for that ? Thanks in advance


Solution

  • I don't know the specifics of the let keyword of RestFixture. But you can use variables using the standard Slim approach to define 'symbols' from decision/script tables. These symbols can then be used in any fixture.

    Using my fixture library you could combine a (Json) Http Test and Compare Fixture to achieve what you describe.