Force test case to fail

Class library usage, coding and language questions.
Posts: 18
Joined: Fri Feb 01, 2013 2:30 pm

Force test case to fail

Post by stefanb » Wed Apr 03, 2013 9:06 am


I have the following set up for my test report:
TestReport.Setup(ReportLevel.Debug, "MyReport.rxlog", true);
TestReport.BeginTestSuite("My TestSuit");
TestReport.BeginTestCase("My TestCase");
TestReport.BeginTestModule("My Test Module");
Report.Screenshot(ReportLevel.Failure, "", "No element found", UI_MainFrame, false);
throw new Ranorex.ElementNotFoundException("No element found", null);
When I look at my report I get the screenshot with a failure, however the test case still passes. How can I make the test case fail? I tried to follow your instructions here ... mples.html and throw an exception but it does not seems to work.

I use a Ranorex .Net Runtime Version 4.0.30319.18034 trial.
I have Windows 7 Proffesional with ServicePack 1 and .Net 4.5

BR Stefan

User avatar
Support Team
Site Admin
Site Admin
Posts: 12169
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA

Re: Force test case to fail

Post by Support Team » Fri Apr 05, 2013 3:43 pm


In order to force the test case to fail, you have to use "Report.Failure("YourMessage")".
Throwing an exception would work if you would work with Ranorex Studio, if you are just using the Ranorex API you also have to take care about the exception handling.