RE: How to ignore a tastcase which fails and start executing further on a same TESTSUIT

Hello All,
I have a Test-suit contain 100 testcases.
Now if suppose my 5 testcase fail then it jump to exception block and my testsuit stop executing for further testcases of same testsuit.
Is there is any way that even if any testcase fails and jump to exception block then TestNG ignore that testcase and start executing further Test cases of respective Testsuit.

shubham Train Asked on September 16, 2014 in Selenium WebDriver.
Add Comment
4 Answers

Hi Shubham,

There can be many ways of doing that and it all depends how you handle the situation in your framework. But the best you can do is to catch the exception in your main test case, then fail the test case (print log , print error, take sreenshot or anything). So you are just eating the exception but still logging it in the logs and all the required steps for a error.

try{
//Your Test Case code
 }catch(Exceptione){
          // If in case you got any exception during the test, it will mark your test as Fail in the test result sheet
          ExcelUtils.setCellData("Fail",iTestCaseRow,Constant.Col_Result);
          // If the exception is in between the test, bcoz of any element not found or anything, this will take a screen shot
          Utils.takeScreenshot(driver,sTestCaseName);
          // This will print the error log message
          Log.error(e.getMessage());
  }

You need to do this exception handing in each of your test case.

Best Regards,
Lakshay Sharma

Professor Answered on September 17, 2014.
Add Comment

Your Answer

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