Page 1 of 1

Abort module but continue within the same test case

Posted: Thu Dec 13, 2012 5:28 pm
by Florian
Hi,

I would like to now if it is possible to abort a module using a specific piece of code, but to continue on the next module within the same test case?

I read this page:
http://www.ranorex.com/support/user-gui ... html#c3028

But it doesn't satisfy my need.

Re: Abort module but continue within the same test case

Posted: Thu Dec 13, 2012 5:55 pm
by Support Team
Hi,

How do you abort the module, do you throw an exception?
If so you could catch the exception Report that an error/failure occurred (Report.Failure(...)) and continue with the next module.

Regards,
Markus

Re: Abort module but continue within the same test case

Posted: Fri Dec 14, 2012 9:46 am
by Florian
Hi,

I tried:

Code: Select all

throw new RanorexException();
But it completely stops the test case.

I tried to put a Report.Failure("myMessage"); but the test case continue within the same module. How can I do ? Do I have to use a try/catch code? For example:

Code: Select all

try {
   action1();
   action2();
   if (event1=true) {
      report.failure("mymessage");
   }
catch (exception e) {
}

Re: Abort module but continue within the same test case

Posted: Mon Dec 17, 2012 11:34 am
by Support Team
Hi,

here is a sample code implementing Markus' description:
try{
    action1();
    action2();
    if (event1==true)
        throw new RanorexException ("Your Exception Text");
    action3();
    action4();
} catch (Exception e)
{
    Report.Failure(e.ToString());
}
action1 and action2 will be executed and if event1 is true an exception will be thrown which will be caught with reporting a failure. Doing so, action3 and action4 will not be executed, and the execution will continue with next module (if the error behavior is set to "Continue with sibling").

Regards,
Tobias
Ranorex Team

Re: Abort module but continue within the same test case

Posted: Mon Dec 17, 2012 11:36 am
by Florian
Thank you very much for your help.
I will try this ASAP :)

Re: Abort module but continue within the same test case

Posted: Wed Dec 19, 2012 10:33 am
by Florian
Yeah OK, I understood! :)

I have to put all the code module inside the "try /catch". The RanorexException stops the try/catch but continue to the following lines after the catch, and to the next module.

Thank you very much!