Better looking test reports with ReportNG
TestNG reports can be customized, so any style modification is possible. Did you know there is this nice ReportNG project, that makes TestNG produce very good looking reports without much trouble ?
Please notice the source code attached at the end of this text.
In the latest blog post I've presented how to create custom reports using test listeners. This time you will see another feature of TestNG in action - reporters.
Original report
For those who are not familiar with TestNG reports, here comes an example - a default report in all its ascetic beauty. :)

ReportNG to the rescue
So, of course you don't want to show such report to your wife/kids/boss. Fortunately:
- TestNG is flexible and extensible, so you can customize it,
- you don't even have to write any code to make report look better, because someone else already did it.
ReportNG (maintained by Daniel W. Dyer) will do the task. After you use it, your test reports will look like this:

or like this (different CSS also provided with ReportNG):

If you want to change it, all you have to do is to customize a CSS file. No real coding required. Sweet.
Build file
Nothing fancy in the build script. Simply inform TestNG that it should use specific reporters.
As usual, Gradle provides simple and elegant solution:
usePlugin 'java'
repositories {
mavenCentral()
mavenRepo urls: 'http://download.java.net/maven/2/'
}
dependencies {
testCompile 'org.uncommons:reportng:1.0'
testCompile 'org.testng:testng:5.10:jdk15@jar'
}
test {
useTestNG()
options {
listeners << 'org.uncommons.reportng.HTMLReporter,
org.uncommons.reportng.JUnitXMLReporter'
}
}
or like this (if you want to use different CSS stylesheet):
...
test {
useTestNG()
options {
listeners << 'org.uncommons.reportng.HTMLReporter,
org.uncommons.reportng.JUnitXMLReporter'
systemProperties.put("org.uncommons.reportng.stylesheet",
"${projectDir}/resources/hudsonesque.css")
}
}
Links
| Attachment | Size |
|---|---|
| 2009_12_testng_reportng.tar_.gz | 1.52 KB |

Tomek, thanks for this. I
Tomek, thanks for this. I have added a link from the ReportNG page as requested and also posted a link on my blog.
Dan Dyer