RE: Looking for such a mechanism so that if any exception occurs while executing the test suite it should mark the corresponding test/method as failed.

Answered

Hi,

I am currently working on a project in which I have mainly created scripts for CRUD operations using Page Factory concepts with TestNG Reporting.

I have put the code for all the main test scripts under try…catch block to handle exceptions. After running the test suite I am able to successfully catch the exceptions in eclipse console. But the problem I am facing is “Results of running suite” (TestNG) tab in eclipse shows all the scrips as passed.

I am looking for such a mechanism so that if any exception occurs while executing the test suite it should mark the corresponding test/method as failed in TestNG report.

Please suggest.

sumitk Train Asked on April 9, 2015 in Selenium WebDriver.
Add Comment
5 Answers

You have to use the org.testng.Assert class to put a failing assert in the catch block. If you want to do it the way you are trying to do it.

Yuo probably need to put Assert.assertTrue(false, <message that you want to print>);

Virender

Professor Answered on April 10, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.