How to Continue to next iteration or jump to a test module

Ask general questions here.
sapra
Posts: 1
Joined: Wed Feb 17, 2016 12:29 am

How to Continue to next iteration or jump to a test module

Post by sapra » Wed Feb 17, 2016 12:38 am

Hi All,

I am new to Ranorex.

My objective is to either execute a testcase or not depending on the test case parameter (e.g. RunTestCase=Y or N)

Therefore, I would like to either skip test case execution to next iteration or to jump to a dummy test module
such that the next iteration continues.

I was thinking of putting a custom code which can read the test case parameter value. however, I am not sure which coding statement to use to indicate that "jump to next iteration".

public bool GetRunTest()
{
bool runTest = testCaseParameters["RunTest"].Equals("P", StringComparison.OrdinalIgnoreCase);
if (!RunTest)
//TestCase.Current.
return;
//return runTest;
}

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

Re: How to Continue to next iteration or jump to a test module

Post by odklizec » Wed Feb 17, 2016 1:50 pm

To run or skip a TC based of a parameter (e.g. Global Parameter) is quite simple. All you need to to is to add a code module before the affected TCs.

Let's say you have TestSuite structure like this:

Code: Select all

[TSRoot]
|_CodeModule.cs <-- here put the code to eval. the global param. and then enable/disable appropriate TCs
|_[TestCase1]
|_[TestCase2]
Then in the code module use code like this:

Code: Select all

    string globalParam= TestSuite.Current.Parameters["gp_NameOfParam"]; //read global parameter value
    if (globalParam == "Yes")  
    {  
        TestSuite.Current.GetTestCase("TestCase1").Checked = true; //enables TestCase1
        TestSuite.Current.GetTestCase("TestCase2").Checked = false; //disables TestCase2    
    }  
    else
    {
        TestSuite.Current.GetTestCase("TestCase1").Checked = false;
        TestSuite.Current.GetTestCase("TestCase2").Checked = true;    
    }
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