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.<anonymous> (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