I am trying to automate application using selenium webDriver + TestNG.
In which I am using multiple assert statement like Assert.assertEquals("Dhaval", "Dhaval1");
and I am trying to catch the assertionfail exception using try& catch block. as i am filling up an excell sheet for test result .
But any how while assertion fails application direct stop execution and catch block is will not execute.
Any suggestion.
Thanks in Advance!!!!
Catching exceptions on test assertions is a bad practice, they are asserts for a reason. What you want to do is implement custom
ITestListener
and define required logic inonTestFailure(ITestResult result)
method, code in this method will be executed if case will fail.