Skip to content

[🐛 Bug]: JUnit reporter addProperty does not work with Cucumber #14721

@TDL-EdgarsEglitis

Description

@TDL-EdgarsEglitis

Have you read the Contributing Guidelines on issues?

WebdriverIO Version

9.19.2

Node.js Version

22.17.0

Mode

WDIO Testrunner

Which capabilities are you using?

What happened?

I want to generate a JUnit test report from Cucumber tests. I have installed @wdio/cucumber-framework and @wdio/junit-reporter, and configured wdio.conf.ts to use the JUnit reporter. Tests run fine, and the report is generated as expected.

Now I want to send this report to Testmo. The standard WDIO JUnit XML report is not particularly well formatted for Cucumber steps (they are all lumped together in the <system-out> section), so I would like to utilize Testmo's feature of extracting Cucumber steps from XML properties. The WDIO JUnit reporter provides the addProperty function that fits this usecase.

Unfortunately, calling addProperty in both the beforeStep and afterStep hooks of the WDIO config file does not result in any properties being added to the testcase in the resulting XML:

    <testcase classname="CucumberJUnitReport-chrome.138_0_7204_101.mac.WDIO JUnit Test" name="JUnit Test" time="0.004">
      <system-out><![CDATA[
✅ Given I am testing WDIO
✅ When I add custom properties
✅ Then they should be in the JUnit report
]]></system-out>
    </testcase>

I also tried the BeforeStep and AfterStep hooks from @wdio/cucumber-framework, with the same effect.

What is your expected behavior?

Custom properties are present in the generated JUnit XML:

    <testcase classname="CucumberJUnitReport-chrome.138_0_7204_101.mac.WDIO JUnit Test" name="JUnit Test" time="0.004">
      <properties>
        <property name="stepnameBefore1" value="Given I am testing WDIO">
        <property name="stepnameAfter1" value="Given I am testing WDIO">
        <property name="stepnameBefore2" value="When I add custom properties">
        <property name="stepnameAfter2" value="When I add custom properties">
        <property name="stepnameBefore3" value="Then they should be in the JUnit report">
        <property name="stepnameAfter3" value="Then they should be in the JUnit report">
      </properties>
      <system-out><![CDATA[
✅ Given I am testing WDIO
✅ When I add custom properties
✅ Then they should be in the JUnit report
]]></system-out>
    </testcase>

How to reproduce the bug.

Here is a minimal reproducible example matching the above XML snippets:
https://github.com/TDL-EdgarsEglitis/wdio-junit-cucumber-test

Relevant log output

See above

Code of Conduct

  • I agree to follow this project's Code of Conduct

Is there an existing issue for this?

  • I have searched the existing issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug 🐛help wantedIssues that are free to take by anyone interested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions