You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(junit): preserve suite identity for hook failures reported from workers (#5664)
* fix(junit): preserve suite identity for hook failures reported from workers
Under run-workers, event.hook.failed for a BeforeSuite/AfterSuite failure
arrives in the main process via Hook.simplify(), which only carries
{hookName, title, error} — no ctx, so the reporter has no way to recover
the owning suite. groupBySuite() then falls back to key = the failure
entry itself, and buildXml's suiteName defaults to "Tests", splitting
each hook failure into its own <testsuite name="Tests"> instead of the
suite that actually failed.
- Hook.simplify() now also serializes suiteTitle/suiteFile/suiteTags
from this.runnable.parent (the real Suite, already used successfully
on the main-thread path — see the "adds suite hook failures as failed
testcases" unit test).
- junitReporter's event.hook.failed listener falls back to these fields
when hook.ctx is absent, reusing one synthetic suite object per
title+file pair so multiple failures from the same worker-reported
suite still group into a single <testsuite>.
Reproduced with the exact scenario from #5645 (BeforeSuite + AfterSuite
both throwing) run via `codecept run-workers 2`: before this change
both failures land under two separate <testsuite name="Tests"> entries;
after, both are under one <testsuite name="My">, matching the
main-thread output shape.
* test(junit): add run-workers regression test for suite hook attribution
Adds an end-to-end regression test that spawns a real run-workers
process against a dedicated fixture (BeforeSuite/AfterSuite both
throwing) with junitReporter enabled, then parses the resulting
report.xml to assert both failures land under the real suite name in
a single <testsuite> element instead of two <testsuite name="Tests">
elements.
Verified this test fails cleanly (not just a timeout) against the
pre-fix junitReporter.js/hooks.js and passes against the fix.
The new fixture lives in its own workers-junit-suite-hooks/ directory
rather than the shared workers/ directory, since several other tests
in this file glob workers/*.js against the base config and would
otherwise pick up the new failing suite and see different pass/fail
counts.
---------
Co-authored-by: kapilvus <kapilvus@gmail.com>
0 commit comments