How to skip test

Best practices, code snippets for common functionality, examples, and guidelines.
siti
Posts: 8
Joined: Tue Oct 20, 2015 8:23 am

How to skip test

Post by siti » Wed Oct 28, 2015 2:14 am

Hi,
Capture1.JPG
Capture1.JPG (22.21 KiB) Viewed 1288 times
Based on the image,
Is it possible to skip test case 2,and jump to test case 3 if test case 1 failed?

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

Re: How to skip test

Post by odklizec » Wed Oct 28, 2015 8:23 am

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
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

siti
Posts: 8
Joined: Tue Oct 20, 2015 8:23 am

Re: How to skip test

Post by siti » Fri Oct 30, 2015 3:14 am

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

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

Re: How to skip test

Post by odklizec » Fri Oct 30, 2015 8:10 am

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?
Last edited by odklizec on Mon Feb 08, 2016 11:46 am, edited 1 time in total.
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

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: How to skip test

Post by gilbar16 » Fri Oct 30, 2015 6:21 pm

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

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

Re: How to skip test

Post by odklizec » Sun Nov 01, 2015 7:47 am

Hi Gilbert,

Of course, you can replace the test case name with whatever you want, including variable holding the test case name.
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

gilbar16
Posts: 109
Joined: Wed Mar 26, 2014 6:23 pm

Re: How to skip test

Post by gilbar16 » Tue Nov 03, 2015 9:51 pm

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

User avatar
jasoncleo
Posts: 37
Joined: Mon Jun 08, 2015 7:37 am

Re: How to skip test

Post by jasoncleo » Mon Nov 16, 2015 8:14 am

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
sample1.png (24.31 KiB) Viewed 1196 times