-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
TestNG Version
7.7.1
IITestListener
Expected behaviour
- Test test passes
- onTestSuccess
- onTestFailure
Actual behaviour
- Test status passes
- onTestSuccess() throws exception
- onTestFailure() is called
- Test is reported as FAILED in the results.
Description
When the test method passes successfully, but an exception is thrown inside the onTestSuccess() listener method, TestNG incorrectly triggers onTestFailure() and marks the test as failed in the report.
The test case results should be based on the test method execution, not on listener behavior. Exceptions in onTestSuccess() should not affect the test status.
This behaviour seems like a bug or regression.
steps to repreduce
add an exception inside onTestSuccesss and check the ressults:
@OverRide
public void onTestSuccess(ITestResult result) {
// Throwing a runtime exception
throw new RuntimeException("exception in onTestSuccess");
}
@Override
public void onTestFailure(ITestResult result) {
System.out.println("onTestFailure was called");
}
note: while debugging the debugger navigated me to the TestInvoker class that update the test failuer to 2 which is FAILUER status then invoked onTestFailuer().