I have the following Java code
import org.testng.annotations.Test;
@Test
public void testException(){
try{
Assert.assertEquals(1,2);
} catch(Exception e) {
e.printStackTrace();
}
}
When the test is run, the assertion fails and exception is printed as standard output and the TestNG shows the test result as FAILED.
If I catch the same exception using
catch(AssertionError e){
e.printStackTrace();
}
the exception is printed as error output and the TestNG shows the test result as PASSED. In both cases exception is handled, but what is the difference here?