JUnit reporter: emit only first failure per testcase#3081
Closed
Krishnayan-Bhatt wants to merge 2 commits intocatchorg:develfrom
Closed
JUnit reporter: emit only first failure per testcase#3081Krishnayan-Bhatt wants to merge 2 commits intocatchorg:develfrom
Krishnayan-Bhatt wants to merge 2 commits intocatchorg:develfrom
Conversation
Aligns with common JUnit tooling expectations (e.g. junitparser) that allow a single result element per testcase. Subsequent assertion failures in the same testcase are omitted from the XML. Fixes catchorg#1919 Made-with: Cursor
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #3081 +/- ##
==========================================
+ Coverage 91.34% 91.35% +0.02%
==========================================
Files 204 204
Lines 8899 8916 +17
==========================================
+ Hits 8128 8145 +17
Misses 771 771 🚀 New features to boost your workflow:
|
horenmar
reviewed
Apr 2, 2026
| // events and write those out appropriately. | ||
| xml.writeAttribute( "status"_sr, "run"_sr ); | ||
|
|
||
| bool resultElementEmitted = false; |
Member
There was a problem hiding this comment.
Why is this outside of writeAssertions?
Author
There was a problem hiding this comment.
You’re right — it doesn’t need to be here anymore. I’ll inline it in writeAssertions (and simplify the signature) in a follow-up commit.
Author
There was a problem hiding this comment.
Done — I moved resultElementEmitted into writeAssertions so it’s only scoped to assertion output. Latest commit: 224a8c2.
Move resultElementEmitted into writeAssertions(); writeSection no longer threads state that is only used while iterating assertions. Addresses review feedback on the JUnit single-failure-per-testcase change. Made-with: Cursor
Member
|
You need either to
As is, this doesn't pass the bar for useful contribution. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The JUnit XML reporter previously emitted multiple
<failure>,<error>, or<skipped>elements for a single<testcase>when several assertions failed (e.g. multipleCHECKs). Common JUnit consumers assume at most one such child per testcase, which breaks tools like junitparser with errors such as “Only one result allowed per test case.”This change tracks whether a result element was already written for the current testcase section and suppresses further assertion result elements after the first.
Related issue
Fixes #1919
Testing
python tools/scripts/approvalTests.py <path-to-SelfTest> <temp-dir>— updatedjunit.sw/junit.sw.multibaselinesctest -C Debug -R RunTests --test-dir <build-dir>