mochajs / mocha

☕️ simple, flexible, fun javascript test framework for node.js & the browser
https://mochajs.org
MIT License
22.52k stars 3k forks source link

🐛 Bug: xUnit XML format is actually JUnit's schema #4758

Open andyleejordan opened 2 years ago

andyleejordan commented 2 years ago

Prerequisites

Description

Hi there,

I feel like I'm crazy, but as far as I can tell, the XML output for Mocha's xUnit reporter is actually JUnit's schema. In short, it's emitting something like:

<testsuite ... >
  <testcase ... />
<testsuite />

Which is most definitely the documented JUnit XML schema. Mocha's own tests for the xUnit output confirm this what it's intended to emit:

https://github.com/mochajs/mocha/blob/0ea732c1169c678ef116c3eb452cc94758fff150/test/reporters/xunit.spec.js#L322-L453

However, the two versions of xUnit XML schema (v1 and v2) look radically different from this! For one, the top-level element must be <assemblies>, which doesn't exist in Mocha's codebase. And neither use <testcase> nor <testsuite> (they both use a <test> element with further information provided by subelements).

I don't know how I'm the first to notice this when this project is used by 1.4 million other things on GitHub, which is why I think I must be wrong, despite staring at the documentation and tests I've just linked that justify this bug is real.

andyleejordan commented 2 years ago

Hey @juergba, any follow up on this, am I crazy?

miensol commented 2 years ago

I'm relieved. I thought I'm missing something as well. Naming things is indeed hard.

miensol commented 2 years ago

What's even more interesting is that apparently this is not the only case where the names about xunit and junit aren't correct. I was trying to verify if Reportportal supports xunit XML files import. I found this class junit/XunitImportHandler.java which only supports junit XML format...

EnricoMi commented 1 year ago

Yes, this is JUnit XML, not XUnit XML.

EnricoMi commented 1 year ago

@jkrall @tj @boneskull what do you think?

JoshuaKGoldberg commented 6 months ago

cc @mochajs/maintenance-crew - looks like this is a long-standing issue that has tripped quite a few folks up. My intuition is we'd want to make a breaking change fix in the next major version that:

Thoughts?

Maverick099 commented 1 month ago

Do we have a timeline for when this issue will be closed?