Rx: Different data sources in debug and release build?

Best practices, code snippets for common functionality, examples, and guidelines.
BCTest
Posts: 127
Joined: Tue Jun 03, 2014 10:15 am
Location: Hamburg, Germany

Rx: Different data sources in debug and release build?

Post by BCTest » Mon Mar 18, 2019 10:50 am

Hi,

is it possible to use different data sources (SqlDataConnector) for debug and release build?
Especially for DataConnectors using a view or a select-statement?

Thanks in advance,
BcTest

User avatar
N612
Posts: 135
Joined: Mon Jul 11, 2016 4:01 pm

Re: Rx: Different data sources in debug and release build?

Post by N612 » Mon Mar 18, 2019 6:33 pm

Hi BCTest,

Regarding changing the SQL data during runtime, I recommend checking out this post:
dynamically-assigning-data-sources-t586 ... ntent24637

Regarding changing the data based on the build configuration, there is a debug constant enabled by default for the 'Debug' and off for 'Release'. This means we can use the below code to dynamically set the sqlQuery for our SQL data connector based on the build configuration.

Code: Select all

#if DEBUG
	string sqlQuery = "abc";
#else
	string sqlQuery = "123";
#endif
I hope this helps!
Last edited by N612 on Tue Mar 19, 2019 4:00 pm, edited 1 time in total.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Rx: Different data sources in debug and release build?

Post by Stub » Tue Mar 19, 2019 8:46 am

I also do something similar, but I examine the AUT path to try and determine if it's a debug or release build. I run a code module which in turn sets a global parameter with its decision. I then use that global parameter as a variable in a Condition on Smart Folders or Test Cases to determine whether certain tests run or not. I could pump in different data sources to the Smart Folders or Test Cases in this way - so far all I've used are the really simple datasources built into Ranorex.

BCTest
Posts: 127
Joined: Tue Jun 03, 2014 10:15 am
Location: Hamburg, Germany

Re: Rx: Different data sources in debug and release build?

Post by BCTest » Fri Mar 22, 2019 11:41 am

Hi,

Thanks for the answers.
I know the possibility of changing a data-connector and use it frequently. But I don't know how to change the data-source for a select-statement. Think of a data-source like "SELECT * FROM table" or "SELECT * FROM view", how to redirect this data-sources to a different database for DEBUG and RELEASE?

The second answer is tricky and seems to be a suitable solution, I'll look for it.

Regards,
BcTest

McTurtle
Posts: 297
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Rx: Different data sources in debug and release build?

Post by McTurtle » Mon Mar 25, 2019 1:48 pm

Hi BcTest,

I think Stubs idea is great. It would enable you to use totally different databases depending on the build as you can connect different data sources to different test containers. It's also not very complicated.

Regards,
McTurtle