Skip to content

junitReporter: run-workers puts each test into its own <testsuite> element #5760

Open

Description

@mirao

With run-workers, the junitReporter plugin puts every test into its own <testsuite> element. A suite with 2 scenarios produces 2 <testsuite> elements with tests="1" each. Plain run groups them correctly.

Reproduced on 4.x (9f371d4), with and without browsers in multiple.

Steps

Config:

export const config = {
  tests: './*_test.js',
  output: './output',
  helpers: { FileSystem: {} },
  plugins: { junitReporter: { enabled: true } },
  name: 'repro',
}

suite_a_test.js (and the same suite_b_test.js with Feature('SuiteB')):

Feature('SuiteA')

Scenario('scenario 1', () => {})

Scenario('scenario 2', () => {})

Run npx codeceptjs run-workers 2 --by suite.

Expected result (what npx codeceptjs run produces):

<testsuite name="SuiteA" id="0" tests="2" ...>
<testsuite name="SuiteB" id="1" tests="2" ...>

Actual result:

<testsuite name="SuiteB" id="0" tests="1" ...>  <testcase name="scenario 1" .../>
<testsuite name="SuiteB" id="1" tests="1" ...>  <testcase name="scenario 2" .../>
<testsuite name="SuiteA" id="2" tests="1" ...>  <testcase name="scenario 1" .../>
<testsuite name="SuiteA" id="3" tests="1" ...>  <testcase name="scenario 2" .../>

Each <testcase> still has the correct classname, so tools that group by classname (e.g. Jenkins) still display the tests correctly. The per-suite totals (tests, failures, time) and the <testsuite> structure are wrong, though.

Cause

groupBySuite() in lib/plugin/junitReporter.js groups tests by the identity of test.parent. Under run-workers, each test arrives in the main process deserialized separately, with its own copy of the parent suite, so no two tests share a parent object. #5664 fixed the same problem for suite hook failures (via a suite-title cache), but not for regular tests. Grouping by a value key (e.g. suite title + file) instead of object identity should fix it.


Created by AI agent (Claude Code)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions