Page 1 of 1

How to skip test

Posted: Wed Oct 28, 2015 2:14 am
by siti
Hi,
Capture1.JPG
Based on the image,
Is it possible to skip test case 2,and jump to test case 3 if test case 1 failed?

Re: How to skip test

Posted: Wed Oct 28, 2015 8:23 am
by odklizec
Hi,

The easiest way to achieve what you want is to set the TC Error Behavior to Continue with sibling, as described here...
http://www.ranorex.com/support/user-gui ... html#c3028

Re: How to skip test

Posted: Fri Oct 30, 2015 3:14 am
by siti
Hi,

If I set 'cont. with sibling' on TC1, it will proceed with TC2.
But what I want is if TC1 failed, it will SKIP TC2 and continue with TC3.

Thanks,
Siti

Re: How to skip test

Posted: Fri Oct 30, 2015 8:10 am
by odklizec
Hi,

In this case, below code should do what you want. Just create a new code module with below code and put it to TearDown section of TestCase1:
if (Ranorex.Core.Testing.TestCase.Current.Status  != Ranorex.core.reporting.activitystatus.Success)
{
    TestSuite.Current.GetTestCase("TestCase2").Checked = false;
}
Hope this helps?

Re: How to skip test

Posted: Fri Oct 30, 2015 6:21 pm
by gilbar16
Hi odklizec,

In your solution, can you use a variable instead of the hard-coded "TestCase2" so that this same code can be used in the other TestCases and just replacing the value of the variable inside each TestCase?

Or maybe better yet is if the hard-coded <name of testcase> can be replaced with a generic one variable like varSkipNextTest where Ranorex automatically detects the next testcase that is "checked".
Or something like "On Failure, skip next testcase selected/checked.".

Thanks.
Gilbert

Re: How to skip test

Posted: Sun Nov 01, 2015 7:47 am
by odklizec
Hi Gilbert,

Of course, you can replace the test case name with whatever you want, including variable holding the test case name.

Re: How to skip test

Posted: Tue Nov 03, 2015 9:51 pm
by gilbar16
Hi Pavel,

Can you please give more details on how or where to add/use variables in the Test Suite?
Perhaps you can give a sample.

You have a Test Suite containing 5 Test Cases, for example TestCase1 to TestCase5. In your sample code as solution, I see "TestCase2" hardcoded. Where in TestCase1 can you set the variable to skip the next testcase which is TestCase2?

Thanks.
Gilbert

Re: How to skip test

Posted: Mon Nov 16, 2015 8:14 am
by jasoncleo
Another alternative, would be considering that "TestCase2" is dependent on "TestCase1", is you could nest TestCase 2 within TestCase1.

That way the "continue with sibling" would ensure that TestCase 2 would get skipped if TestCase1 fails.

It's also good to use the SETUP/TEARDOWN items to ensure stuff such as your "Exit_DVS" always get run to return the AUT to a known state ready for the next test case.
sample1.png