Page 1 of 1

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

Posted: Wed Feb 17, 2016 12:38 am
by sapra
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;
}

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

Posted: Wed Feb 17, 2016 1:50 pm
by odklizec
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?