Skip to content

Fix XML parser dropping spaces between entity-decoded characters#47

Draft
paulboony wants to merge 3 commits intoMicroFocus:masterfrom
paulboony:fix/failed-tests-reported-as-passed
Draft

Fix XML parser dropping spaces between entity-decoded characters#47
paulboony wants to merge 3 commits intoMicroFocus:masterfrom
paulboony:fix/failed-tests-reported-as-passed

Conversation

@paulboony
Copy link
Copy Markdown

@paulboony paulboony commented Mar 30, 2026

Summary

  • Root cause fix: The StAX XML parser in JunitReportReader emits entity references (&gt;, &lt;) as separate Characters events. Spaces between them (e.g. &gt; &lt;) became whitespace-only events that were silently dropped by the isWhiteSpace() filter. This caused step names containing angle brackets like <Token A> <Token B> to be parsed as <Token A><Token B>, breaking the exact-match step name comparison in handlers and misattributing the failure to the wrong step.
  • Fallback safety net: When step name matching fails for any reason, mergeScenario() now enforces the BDD step status invariant (passed* failed skipped*) using a two-pass approach — fill steps first, then locate the failure point and apply the invariant.
  • Handler improvements: All 6 handlers now leave step status null (instead of defaulting to passed) when there is a failure but the step name cannot be matched, enabling the fallback logic to work correctly.

Test plan

  • All 45 existing + new unit tests pass
  • New testEntityEncodedAngleBracketsPreserveSpaces test verifies spaces between entity-decoded angle brackets are preserved
  • Existing integration tests for all 6 BDD frameworks still pass
  • Verify with real JUnit XML containing entity-encoded angle brackets in step names

🤖 Generated with Claude Code

Paul Boonyarungsrit and others added 2 commits March 30, 2026 17:36
When a handler's fillStep() cannot match the failed step name from the
error/stack trace to any OctaneStep (due to name format differences,
encoding, or parsing failures), all steps were incorrectly marked as
PASSED. This adds a fallback in mergeScenario(): if all steps end up
PASSED but the handler detected a test-case-level failure, the last
step is marked FAILED with the error message.

Adds getErrorMessage() to BddFrameworkHandler interface (with default
empty implementation) and implements it in all 6 handlers to expose
the test-case-level error message for the fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The previous fallback marked only the last step as failed when step
name matching failed, leaving all prior steps as passed — including
steps that should have been skipped. This violated the BDD invariant
(passed* failed skipped*).

Two-part fix:
- Handlers: leave step status null (instead of defaulting to passed)
  when there is a failure but the step name cannot be matched. This
  applies to all 6 handlers (CucumberJs already had this behavior).
- mergeScenario: rewrite as two-pass approach — fill all steps first,
  then find the failure point (explicit match > first null with error
  > last resort) and enforce the BDD invariant.

Adds CucumberJs integration test proving the exact pass/pass/fail/
skip/skip pattern when passed steps are individually tracked but the
failed step name has a mismatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@paulboony paulboony marked this pull request as draft April 7, 2026 00:34
The StAX parser emits entity references (e.g. &gt; &lt;) as separate
Characters events. The space between them became a whitespace-only
event that was silently dropped by the isWhiteSpace() filter in
JunitReportReader. This caused step names like
  <Token A> <Token B>
to be parsed as
  <Token A><Token B>
breaking the exact-match step name comparison in handlers and
causing the failure to be misattributed to the wrong step.

Fix: remove the isWhiteSpace() filter and accumulate all Characters
events. The handlers already split by newline and trim lines, so
the extra formatting whitespace is harmless.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@paulboony paulboony changed the title Fix failed tests incorrectly reported as passed in XML output Fix XML parser dropping spaces between entity-decoded characters Apr 8, 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.

1 participant