Differrent behavoir of user code in testsuite and single execution

Best practices, code snippets for common functionality, examples, and guidelines.
Andi
Posts: 5
Joined: Thu Oct 25, 2018 12:33 pm

Differrent behavoir of user code in testsuite and single execution

Post by Andi » Tue Jan 22, 2019 2:28 pm

Hello,

i have a tesmodule:
----------------------------------------------------------
1 action
2 action (usercode)

Code: Select all

  if (atagInfo.Exists(5000))
           		{
            		 Ranorex.Core.Reporting.TestReport.SetCurrentTestResult(TestResult.Passed);
             		Ranorex.Core.Reporting.TestReport.EndTestCaseContainer();
            		 }
              		Else
            		 {
             		Report.Info("You are loggeed out an now logging is starting");
             		}
3 action
----------------------------------------------------------
If I execute tesmodule separatly an in action 2 user code condition is true ranorex has right behavoir and exits the testmodule there.

But if I execute this code in Testsuite and in action 2 condition is true ranorex doesnt exits the tesmodule and goes to action 3.

Anybody idea what im doing wrong?

Thanks for help.

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

Re: Differrent behavoir of user code in testsuite and single execution

Post by odklizec » Wed Jan 23, 2019 9:26 am

Hi,

If I'm not mistaken, there is no (publicly available) way to terminate recording execution, without throwing an exception? I mean, You can easily terminate recording execution by using Validate.Fail() method, but this will throw an exception and set the recording as failed, which is probably not what you want?

The method EndTestCaseContainer simply removes current TestContainerActivity of type TestCase from the ActivityStack. It's a reporting method and how I understand it, it's not intended to be use as a recording stopper ;) Which means, you will either have to use the above mentioned Validate.Fail (or similar) method. Or you need to redesign your recording. Ideally, you should split it into two or more recordings, where in first one, you should evaluate the existence of an element and the next recording(s) should be stored inside a smart folder, which you can enable/disable from the code, based of the existence of evaluated element. This is, in my opinion, much cleaner solution, than killing a recording in the middle? ;)

Oh and there is on more solution! You can convert all steps behind the element evaluation step to user code and put them directly to the evaluation code. But this is something I would personally avoid. Maintaining such recordings is hell ;)
Last edited by odklizec on Fri Jan 25, 2019 12:50 pm, 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

Andi
Posts: 5
Joined: Thu Oct 25, 2018 12:33 pm

Re: Differrent behavoir of user code in testsuite and single execution

Post by Andi » Fri Jan 25, 2019 12:33 pm

Thanks for help! I will cut tescase and put it in to smart folders under conditions.

Greets Andi