How to use the plain name of the running (test) page in Fitnesse?



  • I'm currently exploring FitNesse/Slim as an automated test tool. Scenarios are defined on a page named Example.ScenarioLibrary, and this particular test is defined on Example.T002Scripts.

    I've defined a recurring scenario, which creates a task in the System Under Test, that I want to use in many different tests. However, the task names need to be different. I tried to arrange that by including ${RUNNING_PAGE_NAME} in the Slim table.

    !2 Task configuration
    |scenario        |create new task with duration           |duration                               |
    |click           |New                                                                             |
    |enter           |[TEST] ${RUNNING_PAGE_NAME} @{duration}s|as|Name                                |
    

    This sort-of works, except that this produces the following Name: [TEST] T002Scripts 20s. I want (and expected) it to be [TEST] T002Scripts 20s or [TEST] Example.T002Scripts 20s (both would be fine). Is there any way to get rid of that HTML markup? I've tried other variables (${PAGE_NAME}, ${PAGE_PATH} and ${RUNNING_PAGE_PATH}) but to no avail.



  • I've found a solution in one of the projects which came packaged with my FitNesse installation: hsac-fitness-fixtures. It contains some methods for string manipulation in the form of StringFixture. One of the methods is replace all which allows removing the HTML tags:

    |$testName=|replace all                  |<[^>]*>|in|${RUNNING_PAGE_NAME}|with||
    |enter     |[TEST] $testName @{duration}s|as     |Name                         |
    

    The name of the task is now [TEST] T002Scripts 20s as desired.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2