Sure thing!
If you need help with the SQL stuff, let me know. The only problem I have with the Ranorex SQL data connector is that it is static, which means it runs the same SQL every time unless you change the SQL query right before the test case runs. So, if you have a truly data-driven test, you would need a lot of modules that change the specific query you are about to run.
I use a custom library that has a module that does this for me. I just pass the module the name of the connector I am changing and the query string I want to use now. My test module has variables that hold the information that limits the query (such as a CustomerID or ENVIRONMENT, etc.). It looks like this for my query that gets the different URLs for each environment we might run tests against (TEST, PROD, PREVIEW, etc.):
Code: Select all
public class Set_WEBInfoSQL_for_ENVIRONMENT : ITestModule
{
/// <summary>
/// Constructs a new instance.
/// </summary>
public Set_WEBInfoSQL_for_ENVIRONMENT()
{
// Do not delete - a parameterless constructor is required!
}
string _ENVIRONMENT = "TEST";
[TestVariable("F400087E-BE86-4E24-A2AF-E6EEDC382599")]
public string ENVIRONMENT
{
get { return _ENVIRONMENT; }
set { _ENVIRONMENT = value; }
}
/// <summary>
/// Performs the playback of actions in this module.
/// </summary>
/// <remarks>You should not call this method directly, instead pass the module
/// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
/// that will in turn invoke this method.</remarks>
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
TCS_LIB.Data.SetupSqlDataConnector("WEBInfoSQL", string.Format("exec GetWEBInfo_for_ENVIRONMENT @ENVIRONMENT=N'{0}'", ENVIRONMENT));
}
}
I uses string.Format because it is easier to read than <"exec GetWEBInfo_for_ENVIRONMENT @ENVIRONMENT=N'" + ENVIRONMENT + "'">.
Then TCS_LIB.Data.SetupSqlDataConnector(string, string) looks like this:
Code: Select all
public static void SetupSqlDataConnector(string dataCacheName, string queryString) {
((SqlDataConnector)DataSources.Get(dataCacheName).Connector).Query = queryString;
}
Just drop the module with the code from the top part above into the test suite right before the test case you will be using the data for. Then, you will need to bind the variable just like any other recording module.
This allows you to get results at runtime instead of having to structure the data completely at design time.
Also, I put ALL of my queries inside stored procedures in the DB, so all I have to call from Ranorex is the stored procedure. That way the DB handles data stuff and Ranorex handles test stuff.
Shortcuts usually aren't...