Vale CMS Need more than a rule playground? Explore
Asset Explorer

junit

JUnit XML, a test case per alert, for a CI system that shows test reports but nothing else.

template ci Source

Getting started

Save the file as config/templates/junit.tmpl under your StylesPath, then:

vale --output=junit.tmpl .

junit.tmpl

An output format, named with --output.
{{- /* JUnit XML: a test suite per file and a test case per alert. Errors and
       warnings are failures; suggestions pass, so they are listed but never
       fail the build. */ -}}
{{- $tests := 0 -}}{{- $failures := 0 -}}
{{- range .Files -}}
{{- range .Alerts -}}
{{- $tests = add1 $tests -}}
{{- if ne .Severity "suggestion" -}}{{- $failures = add1 $failures -}}{{- end -}}
{{- end -}}
{{- end -}}
<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Vale" tests="{{ $tests }}" failures="{{ $failures }}">
{{- range .Files -}}
{{- $path := .Path -}}
{{- $n := 0 -}}
{{- range .Alerts -}}{{- if ne .Severity "suggestion" -}}{{- $n = add1 $n -}}{{- end -}}{{- end }}
  <testsuite name="{{ $path | html }}" tests="{{ len .Alerts }}" failures="{{ $n }}">
{{- range .Alerts }}
    <testcase name="{{ .Check | html }}" classname="{{ $path | html }}:{{ .Line }}:{{ index .Span 0 }}">
{{- if ne .Severity "suggestion" }}
      <failure type="{{ .Severity }}" message="{{ .Message | html }}">{{ $path | html }}:{{ .Line }}:{{ index .Span 0 }}: {{ .Message | html }}</failure>
    </testcase>
{{- else }}</testcase>
{{- end -}}
{{- end }}
  </testsuite>
{{- end }}
</testsuites>