Don't understand "Error behavior"

Best practices, code snippets for common functionality, examples, and guidelines.
HansSchl
Posts: 125
Joined: Wed Sep 19, 2018 10:05 am

Don't understand "Error behavior"

Post by HansSchl » Wed May 19, 2021 12:10 pm

Hi friends,

I don't understand what the "Error behavior" option of test cases and smart folders does. I assume it modifies the flow of control when a test step fails, but I don't understand in which way.

I have this test case (curly braces indicate a smart folder):

Code: Select all

test case   ---   with a 3-row data source
+-- [SETUP]
+-- {Preparation}
+-- {TestSteps}
    +--{Test part 1}
    +--{Test part 2}
+-- {Validation}
+-- [TEARDOWN]
The test case has a data source with 3 rows of data.

I want to achieve this: Whenever something fails in [SETUP], [TEARDOWN], or any of the smart folders, I want to skip the rest of the test case, and start the next data iteration.

I created a situation where an action in {Preparation} must fail during the first data iteration. So, the first iteration should skip over {TestSteps} and {Validation}, and then the test should be executed for the second data row (and, finally, for the third row).

I tried setting the "error behavior" of the test case and of the {Preparation} folder to various values but the test never reached the second data row. Is my thinking wrong, or did I just fail to find the correct combination of settings?

Thanks
Hans

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

Re: Don't understand "Error behavior"

Post by odklizec » Thu May 20, 2021 7:43 am

Hi,

What you are looking for is "Continue with iteration" error behavior. In case of error, during one iteration, it will skip the rest of iteration and go to next iteration. However, It will still perform Teardown section of failing iteration! The purpose of Setup/Teardown sections is to always perform setup/cleanup routines. This is by design. So if you don't want to perform Teardown content, you will have to move it elsewhere. Eventually, in case of error, skip it from code.

Here is the code, which helps with disabling teardown section...
viewtopic.php?f=20&t=14513&p=56265#p56195
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

HansSchl
Posts: 125
Joined: Wed Sep 19, 2018 10:05 am

Re: Don't understand "Error behavior"

Post by HansSchl » Thu May 20, 2021 8:01 am

Hi Pavel,

thanks for replying. Actually I'm fine with the SETUP and TEARDOWN sections being executed during each iteration and even in case of error. I was wondering at which level I must set the error behavior. Should the "continue with iteration" be set for each smart folder, for the top-level folders only (Preparation, TestSteps, and Validation), for the test case, or for a combination of these? And (unless it the answer is "for all folders") what should be the error behavior for lower-level folders (Test part 1/2)?

For clarity: Any failed test step in any smart folder should immediately stop the current flow, jump to TEARDOWN, and then restart at SETUP with the next data row (as long as there still is a next row).

Thanks
Hans

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

Re: Don't understand "Error behavior"

Post by odklizec » Thu May 20, 2021 8:53 am

Hi,

OK, I think that in your case, you should set Error Behavior of Test Case to Continue with iteration and any SmartFolder under test case should have Error Behavior set to Continue with parent. So when an error happens in smart folder, it will skip the rest of test and return to parent folder, which is Test Case.

I thinks it's nicely described also in user guide:
https://www.ranorex.com/help/latest/ran ... orbehavior
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