Skip to content

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

Merged
ubmarco merged 1 commit into
masterfrom
worktree-fix-error-state-132
Jun 16, 2026
Merged

Handle JUnit <error> result state in parse_testcase()#134
ubmarco merged 1 commit into
masterfrom
worktree-fix-error-state-132

Conversation

@patdhlk

@patdhlk patdhlk commented Apr 9, 2026

Copy link
Copy Markdown
Collaborator

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

codecov-commenter commented Apr 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.84%. Comparing base (c853346) to head (cb10c95).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #134      +/-   ##
==========================================
+ Coverage   85.60%   85.84%   +0.24%     
==========================================
  Files          28       28              
  Lines        1639     1667      +28     
  Branches      176      177       +1     
==========================================
+ Hits         1403     1431      +28     
  Misses        158      158              
  Partials       78       78              

☔ View full report in Codecov by Harness.
📢 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
@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
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
@ubmarco ubmarco force-pushed the worktree-fix-error-state-132 branch from 1690429 to cb10c95 Compare June 16, 2026 15:35
@ubmarco ubmarco merged commit 15de5df into master Jun 16, 2026
26 checks passed
@ubmarco ubmarco deleted the worktree-fix-error-state-132 branch June 16, 2026 15:40
@ubmarco ubmarco mentioned this pull request Jun 16, 2026
ubmarco added a commit that referenced this pull request Jun 16, 2026
## Release v1.4.0

Bumps the version (`pyproject.toml`, `docs/conf.py`, `test_reports.py`)
and adds
the 1.4.0 changelog for everything merged since 1.3.2.

**Highlights**
- Feature (#135): map JUnit XML `<properties>` to Sphinx-Needs
fields/links.
- Sphinx-Needs 8 support (#133): fields registered via the new
`add_field` API.
- Bugfix (#133): `file`, `suite`, `case`, `case_name`, `case_parameter`
and
`classname` are now registered with a typed schema → default to `None` →
  stripped before schema validation, fixing false-positive
  `Unevaluated properties are not allowed` warnings under
  `unevaluatedProperties: false`. Released 1.3.2 registered them untyped
  (default `""`), which leaked.
- Bugfix (#134): JUnit `<error>` test cases were misclassified as
`passed`; now
  handled correctly in `parse_testcase()`.
- Testing (#130, #137): run against Sphinx-Needs 6.3.0; regression test
that a
  strict schema ignores unpopulated Sphinx-Test-Reports fields.
- Docs (#136, #139): clarify Sphinx-Needs type names vs. the hyphenated
directives; note that numeric `cases` filtering requires Sphinx-Needs >=
6.
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

3 participants