Junit Reporter

Produces HTML reports from the Junit xml output

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.kncept.junit.reporter
ArtifactId

ArtifactId

junit-reporter
Last Version

Last Version

2.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Junit Reporter
Produces HTML reports from the Junit xml output
Project URL

Project URL

https://github.com/kncept/junit-reporter
Source Code Management

Source Code Management

https://github.com/kncept/junit-reporter

Download junit-reporter

How to add to project

<!-- https://jarcasting.com/artifacts/com.kncept.junit.reporter/junit-reporter/ -->
<dependency>
    <groupId>com.kncept.junit.reporter</groupId>
    <artifactId>junit-reporter</artifactId>
    <version>2.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.kncept.junit.reporter/junit-reporter/
implementation 'com.kncept.junit.reporter:junit-reporter:2.1.0'
// https://jarcasting.com/artifacts/com.kncept.junit.reporter/junit-reporter/
implementation ("com.kncept.junit.reporter:junit-reporter:2.1.0")
'com.kncept.junit.reporter:junit-reporter:jar:2.1.0'
<dependency org="com.kncept.junit.reporter" name="junit-reporter" rev="2.1.0">
  <artifact name="junit-reporter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.kncept.junit.reporter', module='junit-reporter', version='2.1.0')
)
libraryDependencies += "com.kncept.junit.reporter" % "junit-reporter" % "2.1.0"
[com.kncept.junit.reporter/junit-reporter "2.1.0"]

Dependencies

runtime (2)

Group / Artifact Type Version
org.apache.maven : maven-plugin-api jar 3.5.4
org.apache.maven.plugin-tools : maven-plugin-annotations jar 3.5.2

test (2)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2

Project Modules

There are no modules declared in this project.

junit-reporter Build Status

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>

Versions

Version
2.1.0
2.0.1
2.0.0