onTestSuccess() Exception incorrectly Triggers onTestFailure() and Fails Test
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- java
- Domain
- testing-qa
Research direction
Start by reproducing the issue with the ITestListener callbacks shown in the report, then inspect TestInvoker where the test failure status is updated after onTestSuccess() throws. Add coverage for this sequence and verify that the test method remains passed, the report remains successful, and onTestFailure() is not invoked.
Written by the indexing model from the issue text.
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().
- Dominant language
- Java
- Stars
- 2.1k
- Forks
- 1k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 38
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from testng-team/testng
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#3672 ·
Maintainers usually reply within 1 day
-
`setXmlSuites` skips a `<suite-file>` that cannot be read, but `setTestSuites` stops the runPossibly taken @sean0407 claimed this 49 days ago. Openarea: xml suites priority: medium roadmap: optional
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#3571 ·
Maintainers usually reply within 1 day
-
area: xml suites contribution: help wanted effort: medium priority: low status: confirmed triage: ai-reviewed type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
testng-team/testng#2641 · 2 comments ·
Maintainers usually reply within 1 day
-
Broken linksOpencontribution: good first issue effort: low priority: low status: confirmed triage: ai-reviewed type: documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
testng-team/testng#2449 · 6 comments ·
Maintainers usually reply within 1 day
-
area: dependency injection area: public api contribution: good first issue effort: low priority: low status: confirmed triage: ai-reviewed type: documentation
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
testng-team/testng#2212 · 4 comments ·
Maintainers usually reply within 1 day
All issues in testng-team/testng
Similar issues
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
eclipse-edc/IdentityHub#1296 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
cloudfoundry/uaa#4194 ·
Maintainers usually reply within 1 day
-
area: ui priority: medium
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
tetsuji16/microProject#1721 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
[Bug] [BanyanDB] timestamp.ParseDuration silently drops everything after "d"Possibly taken @soujasK claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
apache/skywalking#14287 ·
Maintainers usually reply within 1 day