-
-
Notifications
You must be signed in to change notification settings - Fork 219
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
feat: implement JUnit formatter #519
Conversation
src/formatters/junit.ts
Outdated
|
||
for (const result of validationResults) { | ||
output += `<testcase time="0" name="org.spectral.${result.code || 'unknown'}" classname="${classname}">`; | ||
output += `<error message="${xmlEscape(result.message)}">`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question, is it right that we are calling everything an error? Are there ways to highlight warning or info too?
I did a very quick google and found this page:
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites id="20140612_170519" name="New_configuration (14/06/12 17:05:19)" tests="225" failures="1262" time="0.001">
<testsuite id="codereview.cobol.analysisProvider" name="COBOL Code Review" tests="45" failures="17" time="0.001">
<testcase id="codereview.cobol.rules.ProgramIdRule" name="Use a program name that matches the source file name" time="0.001">
<failure message="PROGRAM.cbl:2 Use a program name that matches the source file name" type="WARNING">
WARNING: Use a program name that matches the source file name
Category: COBOL Code Review – Naming Conventions
File: /project/PROGRAM.cbl
Line: 2
</failure>
</testcase>
</testsuite>
</testsuites>
They have failures with a type. I don't know if this is the same version of JUnit or anything, just a real quick search, but if we can find a way to show severity somehow that'd be a bonus, because people will ask.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. I'll try to include it somehow.
<testsuite package="org.spectral" time="0" tests="4" errors="4" name="{document}"> | ||
<testcase time="0" name="org.spectral.api-servers" classname="{documentWithoutExt}"><warning message="OpenAPI `servers` must be present and non-empty array."><![CDATA[line 1, col 1, Warning - OpenAPI `servers` must be present and non-empty array. (api-servers)]]></error></testcase> | ||
<testcase time="0" name="org.spectral.oas3-schema" classname="{documentWithoutExt}"><error message="/info Property foo is not expected to be here"><![CDATA[line 2, col 6, Error - /info Property foo is not expected to be here (oas3-schema)]]></error></testcase> | ||
<testcase time="0" name="org.spectral.info-contact" classname="{documentWithoutExt}"><warning message="Info object should contain `contact` object."><![CDATA[line 2, col 6, Warning - Info object should contain `contact` object. (info-contact)]]></error></testcase> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test shows that the tags are wrong :D throw it in a XML validator on your end when making the scenario and you'll notice that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noticed now 😆.
The parser used in another test handled it fine though, but yeah, agree it's wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philsturgeon updated
Co-Authored-By: Phil Sturgeon <phil@stoplight.io>
Closes #478
Checklist
Does this PR introduce a breaking change?
Make sure to verify whether the output we generate is valid JUnit format.