JUnit: distinguish assertion failures from thrown errors (#39079)#39086
Open
aviavi16 wants to merge 1 commit intomicrosoft:mainfrom
Open
JUnit: distinguish assertion failures from thrown errors (#39079)#39086aviavi16 wants to merge 1 commit intomicrosoft:mainfrom
aviavi16 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Author
@microsoft-github-policy-service agree |
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.
Fixes #39079
Playwright’s JUnit reporter previously serialized runtime / thrown exceptions
(e.g. throw new Error('Boom!')) as , making them indistinguishable from assertion failures (expect(...)).
This PR improves JUnit semantics by clearly separating the two failure types:
Assertion failures → and failures++
Thrown / runtime errors → and errors++
This aligns with standard JUnit conventions and allows downstream CI systems
(Jenkins, Xray, TestRail, etc.) to correctly classify test outcomes.
Changes
JUnit reporter now tracks and emits errors counters at:
Thrown/runtime exceptions are serialized under as
(instead of ).
Assertion failures remain serialized as (unchanged behavior).
Merged reports preserve the same semantics.
Evidence
✅ Baseline behavior (before fix)
Thrown errors were incorrectly reported as , with errors="0":
As a result, tests expecting testcase['error'][0] failed with:
TypeError: Cannot read properties of undefined (reading '0')
✅ Control: assertion failure remains
Assertion failures are still reported as (expected, unchanged):
✅ After fix (new behavior)
Thrown/runtime errors are now correctly classified as and increment
the errors counters.
Created run
Merged run
Tests
Updated / added tests in
tests/playwright-test/reporter-junit.spec.ts validating:
Thrown errors → with errors="1" and failures="0"
Assertion failures → with failures="1" and errors="0"
Merged reports preserve the same semantics