stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.48k stars 233 forks source link

JUnit format should include all passed tests in order to have an accurate failure rate #1555

Open chrif opened 3 years ago

chrif commented 3 years ago

In Azure Pipelines, it makes much more sense to have test results with all passed tests along with the failed ones. We want to publish results even when they pass. And we want to know what percentage of tests failed. Right now if no tests failed, we get an empty xml file:

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
</testsuites>

And when they fail, it includes only the failed ones, so the failure rate is always either 100% or no results to publish.

jrhorn424 commented 3 years ago

I'd also like to request warnings added to JUnit output.

ShauniArima commented 2 years ago

I'd also like to request warnings added to JUnit output.

This is possible by defining the fail-severity option of the command line. It seems it is set to error when the format is defined. Setting it to warn will do the work for your case. In your case the command line will look like this:

spectral lint <path_to_api_file> --format junit --output spectral-report.xml --fail-severity warn
Corbie-42 commented 1 year ago

I'd also like to request warnings added to JUnit output.

This is possible by defining the fail-severity option of the command line. It seems it is set to error when the format is defined. Setting it to warn will do the work for your case. In your case the command line will look like this:

spectral lint <path_to_api_file> --format junit --output spectral-report.xml --fail-severity warn

That is true, but this just adds the warnings as <failure>. Everything below error should be added as <testcase> (see JUnit XML format).