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 executed, the statement fails, and the exception is printed as standard output, and TestNG shows the test result as FAILED.
If I catch the same exception using
catch(AssertionError e){ e.printStackTrace(); }
the exception is printed as an error output, and TestNG shows the test result as PASSED. In both cases the exception is handled, but what is the difference here?
source share