Varying Error Behaviour

Ask general questions here.
kh123
Posts: 10
Joined: Mon Aug 20, 2012 9:39 am

Varying Error Behaviour

Post by kh123 » Wed Oct 17, 2012 9:37 am

Is there any way that I can vary the Error Behaviour of a Test Case dependant on the error within the function ?

I have a function which adds items to a screen. The data is provided by a csv. I have to check that 2 error messages are generated by the AUT.

Error A is serious and I have to stop the test suite at that point.

Error B requires that I report the error as a fail message on the Ranorex report but then continue with the next row of the csv and eventually onto the next test case in the structure

If I set the test case error behaviour to Stop I can get A to work but even if I use try/catch B carries on with the next iteration but will not continue to the next Test case in the structure

If I set the test case error to continue with iteration if Error A is generated the test case continues.

Please bear with me as I have only just started C# coding
Thank you

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

Re: Varying Error Behaviour

Post by Support Team » Wed Oct 17, 2012 1:42 pm

Hi,

No this is not possible, you cannot vary the Error Behavior of a Test Case dependent on the error.
Could you please describe in detail which actions you perform and how you verify which message is shown?
What are you doing when you get Error b, it would help us if you could illustrate your current approach more detailed.

Thanks,
Markus
Ranorex Support Team
.
Image

kh123
Posts: 10
Joined: Mon Aug 20, 2012 9:39 am

Re: Varying Error Behaviour

Post by kh123 » Wed Oct 17, 2012 4:22 pm

What I have is a function which adds items the data is held on a csv
Error A
The items have a name which has to be unique. If the user attempts to add an item where the name is already present on the AUT an error message is generated.

We have to validate this message appears as part of the test so normally we would get the message and report as an error and continue with the next row of the csv.
However due to the nature of the testing there is an issue that if the test script has been run before the data may be present in the system.It was requested that if the message is generated the test be stopped to allow the user to verify the position before continuing with the test

Error B The items require additional data to be input also held on the csv. If this data is incorrect an error message is generated by the AUT. In this case we require to get the message and then move on to the next row of the csv

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

Re: Varying Error Behaviour

Post by Support Team » Thu Oct 18, 2012 5:28 pm

Hello,

I'm afraid that I don't understand what you want to do. Do you want to control the flow of the Ranorex Test depended on the error message of your application? You could use a second Test Case where you execute the modules in case of a specific message. This Test Case can be selected in the previous Test Case as shown below:
TestSuite.Current.GetTestCase("Name of the TestCase").Checked = true;
For the Error B you can generate a Failure and set the 'Error Behavior' to 'Continue with iteration'
I hope that helps!

Regards,
Bernhard
Ranorex Support Team
.
Image

kh123
Posts: 10
Joined: Mon Aug 20, 2012 9:39 am

Re: Varying Error Behaviour

Post by kh123 » Fri Oct 19, 2012 10:11 am

Thank you Bernhard

That's exactly what i want to do.
So what I have to do it
1 add an additional test case to my test suite with the function that I want to execute in the event of a specific error. Setting the error behaviour to what I want. i assume i leave the tese case unchecked so it doesn't run as part of the standard run
2 I add the code as above into my main function in the original test case

Is this correct?

Thank you

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

Re: Varying Error Behaviour

Post by Support Team » Fri Oct 19, 2012 3:30 pm

Hello,

That's correct, but you should insert the code within a module in the teardown region if you want to execute it in case of an error during the Ranorex test.

Regards,
Bernhard
Ranorex Support Team
.
Image

kh123
Posts: 10
Joined: Mon Aug 20, 2012 9:39 am

Re: Varying Error Behaviour

Post by kh123 » Mon Oct 22, 2012 9:07 am

I've just tried this and it works. Thank you Bernhard