Page 1 of 1

How to do interrupt based programming

Posted: Fri Jan 19, 2007 3:25 pm
by arishahsan
How will we implement interrupt based programming using ranorex so that as soon as an error message appears the test case terminate from that
point without executing the rest of the test case.

Posted: Sat Jan 20, 2007 1:28 am
by webops
The easiest way is to use C# and Exception Handling.
If you set the Application.ErrorAsException property, then Ranorex throws a RanorexException every time an operation failed.
You can catch this exception and exit your test case with an error code.

See http://www.ranorex.com/ranorexpro/

Code: Select all

try
{
    Application.ErrorAsException = true;
 
    form = Application.FindFormTitle("RanorexTestedApp");
 
    Button button1 = form.FindButton("button1");
    Mouse.ClickControl(button1);
    ...
    Console.WriteLine("TEST PASSED");
    return 0;
}
catch (RanorexException e)
{
    Console.WriteLine("EXCEPTION Source={0} Sender={1} Message={2}
              StackTrace={3}", e.Source, e.Control, e.Message, e.StackTrace);
    Console.WriteLine("TEST FAILED");
    return 1;
}

Jenö Herget
Ranorex Team

Re: How to do interrupt based programming

Posted: Fri Oct 28, 2011 8:34 pm
by omayer
can't make this code to work - getting this error message - Newline in constant (CS1010) - Console.WriteLine("EXCEPTION

Re: How to do interrupt based programming

Posted: Fri Oct 28, 2011 9:53 pm
by Ciege
You could also start a second thread that checks for error messages or exceptions thrown by your AUT. When one occurs the second thread can tell the main Ranorex thread to abort.