Skip to content
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

Merged
merged 10 commits into from
Sep 17, 2019
Merged

feat: implement JUnit formatter #519

merged 10 commits into from
Sep 17, 2019

Conversation

P0lip
Copy link
Contributor

@P0lip P0lip commented Sep 3, 2019

Closes #478

Checklist

  • Tests added / updated
  • Docs added / updated

Does this PR introduce a breaking change?

  • Yes
  • No

Make sure to verify whether the output we generate is valid JUnit format.

@P0lip P0lip added the enhancement New feature or request label Sep 3, 2019
@P0lip P0lip added this to the Sept '19 milestone Sep 3, 2019
@P0lip P0lip self-assigned this Sep 3, 2019
@P0lip P0lip marked this pull request as ready for review September 10, 2019 12:31
philsturgeon
philsturgeon previously approved these changes Sep 10, 2019

for (const result of validationResults) {
output += `<testcase time="0" name="org.spectral.${result.code || 'unknown'}" classname="${classname}">`;
output += `<error message="${xmlEscape(result.message)}">`;
Copy link
Contributor

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.

Copy link
Contributor Author

@P0lip P0lip Sep 16, 2019

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.

EDIT:
https://stackoverflow.com/a/14029143

<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>
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@philsturgeon updated

P0lip and others added 2 commits September 17, 2019 22:07
Co-Authored-By: Phil Sturgeon <phil@stoplight.io>
@P0lip P0lip merged commit 7eb8deb into develop Sep 17, 2019
@P0lip P0lip deleted the feat/junit branch September 17, 2019 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatter: JUnit
2 participants