简体   繁体   中英

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

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?

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$

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM