This is a migrated thread and some comments may be shown as answers.

Configuration File - Database Connection String

4 Answers 132 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top Gun
Top achievements
Rank 1
Top Gun asked on 10 Jul 2012, 02:50 AM

I have an automated test that runs against a Silverlight application.  At some points I connect to the database to verify that the data persisted correctly.  In these cases, I write code in a test step to connect to the database.  I use a hard coded connection string in my coded step.  The only problem is that my Silverlight application may be using different databases depending on the environment.  (i.e.  QA, Dev, Production)  I do not want to change my connection string (in every coded step) every time I go against a different database.  Is there a better way to easily change my connection string when I am running my automated test? Maybe there is a global setting or configuration file that I may use to put these values.  What is the best way to handle this situation?  Please let me know.

4 Answers, 1 is accepted

Sort by
0
Anthony
Telerik team
answered on 10 Jul 2012, 01:35 PM
Hello Top Gun,

I think the simplest approach is to craft a conditional statement based on ActiveBrowser.Url. If it matches QA, use Connection String 1. If it matches Dev, use Connection String 2, etc.

Kind regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Top Gun
Top achievements
Rank 1
answered on 10 Jul 2012, 03:38 PM
Ok.  I think I see what you are saying.  The Url that I use to open the webpage will determine the database connection string to use. In this scenario, I am still confused how to use different URLs.   For example, when I record a test I enter a specific URL.  When I run the test for a different environment, how would I specify a different URL so the automated test opens the correct website?

For my situation, I am not using URLs to open a website.  I am opening a Silverlight Out of Browser application.  So no URL is used to open the application.  But, I need a way to tell the test automation tool to use a specific configuration file (or something) so it knows what database connection string to use.  I hope this make sense.
0
Anthony
Telerik team
answered on 10 Jul 2012, 05:03 PM
Hello Top Gun,

To run a test (or test list) in multiple environments, use the BaseURL feature. You can create three test lists, each pointing to different BaseURL.

You can certainly write some basic .NET code to open and read from a file on disk to determine which connection string to use. What might be easier is set the BaseURL (even though your OOB test isn't using it), and use the following string in your conditional statement to select the correct connection string:

string baseUrl = ExecutionContext.Settings.BaseUrl;


Regards,
Anthony
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Top Gun
Top achievements
Rank 1
answered on 11 Jul 2012, 07:05 PM
There seems to be an issue running a list on an OOB application.  See the link below.

http://www.telerik.com/automated-testing-tools/community/forums/test-studio/general-discussions/test-list-not-running-on-oob-application.aspx#2182701

So I guess the easiest way would be to update the BaseURL address each time I run an automated test in a different environment.  In this case, the scripts would evaluate the BaseURL address to determine which connection string to use.
Tags
General Discussions
Asked by
Top Gun
Top achievements
Rank 1
Answers by
Anthony
Telerik team
Top Gun
Top achievements
Rank 1
Share this question
or