0

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?

  • 2
    Hi Akshya, Welcome to Stack Overflow! :) When you're posting questions it would be really helpful to post what you already have. That way it becomes easier for the person helping to see what you already have. – Shrayas Nov 25 '16 at 11:18
  • Have you considered using a variable via `!define` (http://fitnesse.org/FitNesse.UserGuide.FitNesseWiki.MarkupLanguageReference.MarkupVariables) to store your connection string? You can then have a single suite that defines what to test, and reference that via 'symbolic links' (http://fitnesse.org/FitNesse.UserGuide.FitNesseWiki.SymbolicLinks) to have a suite per environment. So then you get the best of both worlds: single definition of what queries and ability to execute against different environments by selecting which suite to run. – Fried Hoeben Nov 25 '16 at 13:26
  • Dbfit allows you to hold your connection strings in a file - see "Connect Using File" in http://dbfit.github.io/dbfit/docs/reference.html – Ed Harper Dec 07 '16 at 13:14

1 Answers1

0

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$
user272735
  • 10,473
  • 9
  • 65
  • 96