Abort module but continue within the same test case

Ask general questions here.
Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Abort module but continue within the same test case

Post by Florian » Thu Dec 13, 2012 5:28 pm

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.

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Abort module but continue within the same test case

Post by Support Team » Thu Dec 13, 2012 5:55 pm

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

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Abort module but continue within the same test case

Post by Florian » Fri Dec 14, 2012 9:46 am

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) {
}

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Abort module but continue within the same test case

Post by Support Team » Mon Dec 17, 2012 11:34 am

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

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Abort module but continue within the same test case

Post by Florian » Mon Dec 17, 2012 11:36 am

Thank you very much for your help.
I will try this ASAP :)

Florian
Posts: 75
Joined: Fri Jul 27, 2012 12:57 pm
Location: France (Lyon)
Contact:

Re: Abort module but continue within the same test case

Post by Florian » Wed Dec 19, 2012 10:33 am

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!