Run Configuration and Data Binding

Ask general questions here.
tedel
Posts: 5
Joined: Wed Oct 30, 2019 2:47 pm

Run Configuration and Data Binding

Post by tedel » Wed Oct 30, 2019 3:37 pm

Hi,

i have searched through the forum already and the only entry matching was this post:

https://www.ranorex.com/forum/run-confi ... 10842.html

My situation is like this:

I have a Ranorex Solution for the programm i am supposed to test. I now implemented basic tests like is it possible to login and does the happy path for features work with a minimum of testdata. This runs in CI after each build with a sql database as datasource. Now i want to make reuse of the tests as they are already definded and do things based on the data they get from the datasource. I want to run execalty the same tests but with a way bigger dataset over the weekend so that i have a larger test coverage.

So the idea was to create another run config which then triggers the same testcases but has a) an other datasource or b) uses different entries from the same datasource (which i can do with conditions as far as is understood it).

The post mentioned above now tells me that this is not possible.

Only Option which i found is to copy the Testcases and select them for the "long" runconfig and then give them a larger set of data by a) an other datasource or b) via conditions.
But when i do that i have to take care of all testcases in the runconfigs twice when it comes to maintanace or extending the testcases..i then do not get the whole point of data driven testing approach of ranorex as it is not useable like that (at least for me).

Maybe i missunderstood something or anybody knows a better way of reusing tests with a larger dataset without copy them and simultaneously make use of data driven testing approach.

tedel
Posts: 5
Joined: Wed Oct 30, 2019 2:47 pm

Re: Run Configuration and Data Binding

Post by tedel » Wed Nov 06, 2019 8:58 am

i meanwhile created a feature request for this : https://uservoice.ranorex.com/forums/15 ... -runconfig

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5360
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Run Configuration and Data Binding

Post by odklizec » Wed Nov 06, 2019 10:41 am

Hi,

Absolutely agree with you that Run Configuration needs some improvements. Remembering Data Range would be just perfect. And I would also add remembering of manually disabled modules. This would be great for debugging purposes.

As for your problem, I'm personally solving a similar issue by using code module, placed in Setup section of Test Suite, which contains below code:

Code: Select all

if (typeOfTest=="smoke")
{
    TestSuite tS = (TestSuite)TestSuite.Current; 
    IList<TestSuiteEntry> ss =tS.GetAllTestSuiteEntries();
    foreach(TestSuiteEntry x in ss)
    {
        if((x.GetType()== typeof(TestCaseNode) && x.Parent.GetType()!=typeof(SmartFolderNode) && !x.DisplayName.Contains("Test suite")) | (x.GetType()== typeof(SmartFolderNode) && x.DisplayName.Contains("_loop")))
        {
            Report.Log(ReportLevel.Info,x.DisplayName);
            var getTestCase = TestSuite.Current.GetTestContainer(x.DisplayName);
            getTestCase.DataRange.MinRange = 0;  
            getTestCase.DataRange.MaxRange = 0;   
            getTestCase.DataContext.SetRange(getTestCase.DataRange.MinRange,getTestCase.DataRange.MaxRange);  
            Report.Log(ReportLevel.Info, "Setting Data Range", "TestCaseName range:" + "\nMin: " + getTestCase.DataRange.MinRange.ToString() + "\r\nMax: " + getTestCase.DataRange.MaxRange.ToString());	
        }
    }
}
Where 'typeOfTest' is passed via command line. All TC data connectors are, by default, set to use entire data range. And if I want to run only 'smoke' test, the above code simply goes over entire test suite tree and sets new data range to each found TC, with few exceptions (the code ignores Smart Folders, TCs with '_loop' string in name and Test Suite folder). Hope this helps? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

tedel
Posts: 5
Joined: Wed Oct 30, 2019 2:47 pm

Re: Run Configuration and Data Binding

Post by tedel » Wed Nov 06, 2019 11:08 am

Hi,

thanks for that. I did not know that i can access the Ranorex Stuff like that.
This is at least a nice workarround :)

Problem is that we do the databinding at smartfolders.
Currently all database entries already have a field which indicates for which runconfig they are meant to run so it would be nice if i could find any way to make use of that..not sure if this is already possible in setup section of Testsuite..but i think i'll find a way.
I'll try this in one of the next sprints and post my solution if i found something.

Thanks again!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5360
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Run Configuration and Data Binding

Post by odklizec » Wed Nov 06, 2019 11:51 am

Hi,

So you can simply change this line:

Code: Select all

if((x.GetType()== typeof(TestCaseNode) && x.Parent.GetType()!=typeof(SmartFolderNode) && !x.DisplayName.Contains("Test suite")) | (x.GetType()== typeof(SmartFolderNode) && x.DisplayName.Contains("_loop")))
to this:

Code: Select all

if(x.Parent.GetType()==typeof(SmartFolderNode) && x.GetType()!= typeof(TestCaseNode) && !x.DisplayName.Contains("Test suite"))
Basically, it will ignore TCs and allow to change Data Ranges in SmartFolders. Hope this helps? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

tedel
Posts: 5
Joined: Wed Oct 30, 2019 2:47 pm

Re: Run Configuration and Data Binding

Post by tedel » Mon Nov 25, 2019 10:06 am

Thanks to @odklizec and ranorex support i found a solution that is suitalbe for my tests :

The precondition is that you use sql database as datasource and that you have an entry in each table representing the runconfig.

In an other post here i found how to read out current run config :

Code: Select all

string runConfig = TestSuite.Current.SelectedRunConfig.Name.ToString();
With that and the ability to manipulate the sql querry during runtime you can achive selcting runconfig specific entry from the database:

Code: Select all

 
     // Read out runconfig
      string runConfig = TestSuite.Current.SelectedRunConfig.Name.ToString();

      // iterate over all data connectors
      foreach(Ranorex.Core.Data.DataCache oDataCache in TestSuite.Current.DataConnectorCaches)
      {
        // if current dataconnector is of type sqldataconnector do something
        if(oDataCache.Connector.ToString().ToLower() == "ranorex.core.data.sqldataconnector")
        {
          // get the actual querry and add the where condition saying which runconfig should be used
          Ranorex.Core.Data.SqlDataConnector oConn=(Ranorex.Core.Data.SqlDataConnector)oDataCache.Connector;
          oConn.Query = oConn.Query + " where runconfig like '" + runConfig + "';";
        }
      }
You then only have to add a codemodule with that code to your solution and execute it in SETUP section of your Test suite.

This is stripped down to the basic solution and i think in most cases you'll have different conditions regarding database or setup.
My point is you can achieve selecting data depending on runconfig.

Looking at the TestSuite.Current Object is a good idea if you ever feel the need to manipulate any of the ranorex settings during runtime