New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JUnit reporter XML output missing required classname attribute on testcase element #11068
Comments
Hi @micheee, thanks for the issue. I agree this seems like a bug, but I'm not sure what value we should put in there. Do you have any thoughts? |
How about an empty string? |
We ran into this also. To me, the filename would be useful |
Some example of how other test tools fill
|
The Filename — maybe without the extension — would be my proposal as well. Any other thoughts? |
Thanks everyone for your suggestions! Re: filename: It looks like the filename is captured in the And I guess I'm a bit skeptical about looking at other test runners for examples. Not sure if those are really apples-to-apples comparisons. If empty string will work (i.e., if the attribute being "required" in the XSD means the attribute just needs to be present, but it doesn't have to have a non-empty value), I could get behind that. I could also support a value like "Linter", since that's the name of our (ES6) class that is doing the linting. @micheee Can you test out whether |
Sorry I've been in the mountains for the weekend — I will check this out today and report back. |
Long story short: Setting classname to empty string would be valid, but won't help GitLab as it uses So I'd propose to change the value of classname to the name attribute of its parent testsuite element, ore more profane: the full path to the file under consideration. My example report contains 18 errors of the category If I however change the classname to the file path (I'd vote for that because filenames like index.js are very likely to show up more than once in any given codebase) the results are shown mostly correct in the UI — multiple errors of the same category per File will only show up once — but I don't think that's something eslint should tackle. Feedback appreciated. |
@micheee, |
What do you think, I could send a PR containing the required change? |
@micheee What value would you want to use? I don't think we came to consensus on that, did I miss something? |
@platinumazure Sorry, I did not want to rush things. I am locally playing around with using the filepath, but trimmed relative to the project root and without the filename suffix to have a things a little more readable for humans. Currently it I imagine something like this: <?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite package="org.eslint" time="0" tests="1" errors="0" name="/Users/michael/Code/foo/foo-dev/src/frontend/controllers/PageController.js">
<testcase time="0" name="org.eslint.no-console" classname="src/frontend/controllers/PageController">
<failure message="Unexpected console statement."><![CDATA[line 41, col 9, Error - Unexpected console statement. (no-console)]]></failure>
</testcase>
</testsuite>
</testsuites>
Still this decision is kind of arbitrary as obviously the reporting format was invented for Java. Feedback is very welcome. :) |
Sounds like a reasonable proposal. Any news here? |
If I am not mistaken by the JUnit schema, |
Unfortunately, it looks like there wasn't enough interest from the team Thanks for contributing to ESLint and we appreciate your understanding. |
ref discussion: eslint#11068
When producing JUnit XML output, the resulting XML file seems to be missing required attributes.
I found the following XML Schema Definition that indicates the required fields.
While I don't think it is necessary to support every optional attribute, I think it would make sense to provide those that are mandatory.
I stumbled across this, as I tried to integrate ESlint output in GitLab CI, but GitLab CI will not display the report, as it requires the classname attribute to be present.
There is also an issue filed over at GitLab, but maybe it was more obvious to fix the issue in ESlint.
If you think here’s the right place to fix this, I'd be happy to contribute a Pull Request.
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration: ø
Configuration
What did you expect to happen?
Expected the attribute
classname
to be present on element<testcase />
— I suggest that classname will be set tobasename
of the parents<testsuite/>
file
attribute.What actually happened? Please include the actual, raw output from ESLint.
Are you willing to submit a pull request to fix this bug?
👍
The text was updated successfully, but these errors were encountered: