junit-reporter
A plugin to convert XML test results to HTML and perform some aggregation.
There is no config required by default.
Also useful if you need the XML files and still want a human-readable output.
Gradle
Applying the easy way
This plugin is now released as a community plugin
plugins {
id 'com.kncept.junit.reporter' version '2.1.0'
}
Applying the long way from maven central
Add or merge this to the top of your buildscript libraries via the mavenCentral repository:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.kncept.junit.reporter:junit-reporter:2.1.0'
}
}
Then, apply the plugin:
apply plugin: 'com.kncept.junit.reporter'
Plugin Execution
The task 'junitHtmlReport' will run as a finalizer after the 'test' or 'check' tasks.
If you want more fine grained control, add it as a finalizer to another task. eg:
junitPlatformTest.finalizedBy 'junitHtmlReport'
And you're done!
Reports are generated into the gradle 'reports' directory.
eg: junit-reporter/build/reports/tests/junit-platform/index.html
Please be aware that the plugin may take a few hours to become available after release.
Configuration Options
If you need to do any customisation (changing output directories, or you just don't like red...), Its possible to customise. Use the following config block (shown with default values):
junitHtmlReport {
// The maximum depth to traverse from the results dir.
// Any eligible reports will be included
maxDepth = 3
//RAG status css overrides
cssRed = 'red'
cssAmber = 'orange'
cssGreen = 'green'
//Processing directories
testResultsDir = 'test-results'
testReportsDir = 'reports/tests'
//Fail build when no XML files to process
failOnEmpty = true
}
Command Line Usage
Command line support has been built.
The jar file is executable, and the options have the same names as in build configuration blocks.
The main class name is com.kncept.junit.reporter.TestReportProcessor.
Options use a simple equals sign.
eg: java -jar junit-reporter-2.1.0.jar failOnEmpty=false
to process reports in the current dir
An extra 'dir' arg that sets the Results and Reports dir in one go is included:
eg: java -jar junit-reporter-2.1.0.jar failOnEmpty=false dir=~/path/
to process reports in the ~/path/ dir
Maven (Experimental support only)
Maven doesn't like running plugins after test failures. The plugin can be run directly (assuming the configuration below) with the following command:
mvn com.kncept.junit.reporter:junit-reporter:2.1.0:junit-reporter
Applying
In the project/build/plugins element, add the plugin. Suggested execution binding is for the 'verify' phase.
<plugin>
<groupId>com.kncept.junit.reporter</groupId>
<artifactId>junit-reporter</artifactId>
<version>2.1.0</version>
<executions>
<execution>
<id>junit-reporter</id>
<phase>verify</phase>
<goals>
<goal>junit-reporter</goal>
</goals>
</execution>
</executions>
</plugin>
Configuration Options
Add the configuration element to the junit-reporter plugin element.
Defaults are shown below, just delete what you don't need.
<configuration>
<maxDepth>3</maxDepth>
<cssRed>red</cssRed>
<cssAmber>orange</cssAmber>
<cssGreen>green</cssGreen>
<failOnEmpty>true</tailOnEmpty>
</configuration>