fitnessefitnesse-slim

How to use a runtime variable in FitNesse


Let's say I have the following FitNesse page:

!| com.myproject.fitnesse.fixtures.SSHFixture |
| set host | ${hostSi1} |
| set port | ${port} |
| set user | ${user}  |
| connect |
| show | run command | pwd |
| disconnect |
www.<variable>.com

The page contains one table and a link. The table will execute the console command pwd. How do I save the result of that command in a FitNesse Variable? I want then to use the variable within the same page. For example in the mentioned link.

Some resources are mentioning SLIM style, but I have no idea how to accomplish that in my case: Using data from fitnesse table as a variable


Solution

  • @Fried Hoeben: Yes its a script. Got a solution from my colleague.

    Let's say you have Fixture for DB stuff and there's method called 'execute query' which will return result of the query.

    Setting value to variable 'myname' so we could use in another fixture table as '@{myname}'.

    !| com.mystest.fitnesse.fixtures.DBFixture |
    | set database | ${dbName} |
    | set username | ${dbUser} |
    | set password | ${dbPassword} |
    | connect | ${dbType} | to | ${dbUrl} | database | ${dbPort} |
    | set | myname | execute query | SELECT name FROM customer WHERE id = 1 |
    | disconnect |
    

    Use of variable 'myname':

    !| com.mytest.fitnesse.fixtures.SSHFixture |
    | set host | ${host}                   |
    | set port | ${port}                   | 
    | set user | ${user}                   |
    | connect                              |
    | show     | execute|echo @{myname} |  
    | disconnect                           |
    

    Not sure if the feature of set is part of fitnesse default impl. or of our company implementation.