How to read the connection string from a file in fitnesse?

572 Views Asked by At

I want to test different queries, in fitnesse using dbfit, on a table present in different environment. Each environment has a different connection string. So instead of creating multiple pages for each environment(which is again a tedious task since each time a single change in the query may lead to change in all the test pages), I would like to store the connection string in a single file(may be text or excel sheet) and read the connection string out of it according to the requirement.

Can anyone help me out on how to proceed?

1

There are 1 best solutions below

0
user272735 On

I'm not sure if the following is perfect fit for your requirements but I have an own "configuration" page for each database. Then I simply include the configuration page in the each of the test pages:

!include -c .DbFitSetup.UseDbX

You can switch the database during the test simply by including new configuration as the example below demonstrates:

user272735@dev:~/test/FitNesseRoot$ cat DbFitSetup/UseDbX/content.txt 
!path lib/*.jar
!|dbfit.OracleTest|
!|Connect|dbx.example.com:1531|<username>|<password>|dbx|
user272735@dev:~/test/FitNesseRoot$ cat DbFitSetup/UseDbY/content.txt 
!path lib/*.jar
!|dbfit.OracleTest|
!|Connect|dby.example.com:1531|<username>|<password>|dby|
user272735@dev:~/test/FitNesseRoot$ cat ExampleTestSuite/ExampleTest/content.txt 
!include -c .DbFitSetup.UseDbX

!|inspect query|select sysdate, global_name as db_name from global_name|

!include -c .DbFitSetup.UseDbY

!|inspect query|select sysdate, global_name as db_name from global_name|
user272735@dev:~/test/FitNesseRoot$