Skip to content

Handle JUnit <error> result state in parse_testcase()#134

Open
patdhlk wants to merge 1 commit intomasterfrom
worktree-fix-error-state-132
Open

Handle JUnit <error> result state in parse_testcase()#134
patdhlk wants to merge 1 commit intomasterfrom
worktree-fix-error-state-132

Conversation

@patdhlk
Copy link
Copy Markdown
Collaborator

@patdhlk patdhlk commented Apr 9, 2026

Summary

Fixes #132

  • parse_testcase() now explicitly handles the JUnit <error> element, which represents unexpected exceptions or infrastructure crashes
  • Previously, <error> test cases were silently classified as "passed" (false-positive verdict)
  • Adds CSS styling for the tr_error result type (orange, distinct from failure red and skip gray)
  • Also guards against None text in <failure> elements (consistency with the <skipped> branch)

Changes

  • sphinxcontrib/test_reports/junitparser.py — Add elif hasattr(testcase, "error") branch before the else clause
  • sphinxcontrib/test_reports/css/common.css — Add tr_error row and status badge styles
  • tests/doc_test/utils/xml_data_error.xml — New test fixture with all four result states
  • tests/test_junit_parser.py — New test_parse_error_xml() covering error parsing

Test plan

  • New test_parse_error_xml verifies error result, type, message, and text extraction
  • All 31 existing tests continue to pass
  • No changes to rendering logic needed — existing "tr_" + result pattern handles the new state automatically

@patdhlk patdhlk force-pushed the worktree-fix-error-state-132 branch from 87a359d to 0b350c8 Compare April 10, 2026 18:54
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.50%. Comparing base (529246a) to head (20764c0).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   84.16%   84.50%   +0.33%     
==========================================
  Files          26       26              
  Lines        1295     1323      +28     
  Branches      156      157       +1     
==========================================
+ Hits         1090     1118      +28     
  Misses        134      134              
  Partials       71       71              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@patdhlk patdhlk requested a review from danwos April 11, 2026 20:16
Previously, test cases with an <error> element were silently classified
as "passed" because the if/elif/else chain only checked for <skipped>
and <failure>. This is a false-positive verdict — errors indicate
unexpected exceptions or infrastructure crashes, not passing tests.

- Add explicit handling for the <error> element in parse_testcase()
- Add CSS styling for the tr_error result type (orange)
- Also fix potential None in failure text (use `or ""` guard)
- Add test fixture and test case for error state parsing

Closes #132
@patdhlk patdhlk force-pushed the worktree-fix-error-state-132 branch from 0b350c8 to 20764c0 Compare April 13, 2026 06:23
@patdhlk patdhlk self-assigned this Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parse_testcase() silently maps JUnit <error> and unknown result states to "passed", causing false-positive test verdicts

2 participants