How to create a config file and access in FitNesse?

168 Views Asked by At

How do I create a config file and call within FitNesse test suites in Java?

I have multiple FitNesse test suites with repeating url link, and I would like to move those url to a config file and call directly within the FitNesse test suites.

Sample FitNesse tests:

|request payload |${post}|
|keyTab url| 'home/data/file'|
|url|https://google.com|

Recurring URL in all FitNesse tests:

|keyTab url| 'home/data/file'|
|url|https://google.com|

Trying to move the recurring URLs to a config file and call the file within all the FitNesse tests.

  1. How do I create a XML (config) file for the URLs?
  2. How do I call the XML file in FitNesse Test Suites?
2

There are 2 best solutions below

1
Tom Heintzberger On

Does it have to be XML? That would require a custom fixture.

FitNesse does provide the option to load a configuration file that you can provide with the -f filename.properties command line argument (default: plugins.properties).

Apart from FitNesse's own configuration properties, any custom property you provide here, can be accessed using ${propertyName} in the wiki and will be translated to its value.

0
Fried Hoeben On

Does it have to be a separate file, outside the wiki? Otherwise I would recommend just defining the repeating config values in the top-level page of your suite using !define KEY_TAB_FILE {'home/data/file'}. Then all test pages can just use ${KEY_TAB_FILE} to access the value.

In parent page:

!define KEY_TAB_FILE {'home/data/file'}
!define URL {https://google.com}

In test pages the values are specified using these values

|request payload |${post}|
|keyTab url|${KEY_TAB_FILE}|
|url|${URL}|

With this approach you can also reuse the test pages for different environments using symbolic links (e.g. different URLs to test). The same test pages are linked between different root pages that specify different values for the parameters.