Skip to content

🐛 Bug: xUnit xml format uses errors not failures #4483

Open

Description

Hello,

We are using the built-in xUnit reporter as part of Mocha and are running into an issue where the xml generated treats assertion failures as errors. Specifically, when a test fails as a result of an assertion, the errors attribute on the element is used rather than the failures attribute.

/* Actual output /
<testsuite name="Mocha Tests" tests="4" failures="0" errors="1" skipped="0" timestamp="Tue, 20 Oct 2020 15:24:27 GMT" time="136.099">
/
Expected output */
<testsuite name="Mocha Tests" tests="4" failures="1" errors="0" skipped="0" timestamp="Tue, 20 Oct 2020 15:24:27 GMT" time="136.099">

Ultimately for us, this causes the test report functionality of Bitbucket Pipelines to fail rendering the xml output. Comparing Jnit xml output, it uses the failures attribute for assertion failures rather than errors, which seems correct to me.

My expectation would be that errors are used for test execution problems, not test assertion failures and seems like it should be a bug. I have included the xml output below.

<testsuite name="Mocha Tests" tests="1" failures="0" errors="1" skipped="0" timestamp="Tue, 20 Oct 2020 15:24:27 GMT" time="136.099"> <testcase classname="Class Tests" name="should test the class" time="13.213"> <failure>Setting an on purpose fail so I can see if xunit results are being reported. AssertionError [ERR_ASSERTION]: Setting an on purpose fail so I can see if xunit results are being reported. at Context.&lt;anonymous&gt; (test/sample/sample.test.ts:76:16) at processTicksAndRejections (internal/process/task_queues.js:97:5)</failure> </testcase> </testsuite>

What is the expectation of errors vs failures for the xml file? We can work around the issue by post processing the xml file, but wanted to see if I should report a bug on this issue, or if it's working as expected.

Thanks,

Kevin

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

Metadata

Assignees

No one assigned

    Labels

    area: reportersinvolving a specific reportersemver-majorimplementation requires increase of "major" version number; "breaking changes"status: accepting prsMocha can use your help with this one!type: buga defect, confirmed by a maintainer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions