Posts Tagged ‘reportng’

TestNG is a testing framework created as an annotation driven alternative for JUnit 3 in times when “extends TestCase” was an indispensable part of writing tests. Even now it provides some interesting features like data providers, parallel tests execution or test groups. In the situation our tests are not executed from IDE it’s often useful to take a look at a test result in a HTML report. The original TestNG report looks… raw. What is more it is not very intuitive and readable. There is an alternative – ReportNG. It provides a better looking and more lucid HTML test reports.

More information about ReportNG can be found at its webpage, but when I tried to use for my AppInfo library in Maven builds running from a CI server I had a problem to find any at a glance guide how to use it with Maven. Fortunately there are samples for Ant and Gradle, so I was able to figure it out, but I hope with this post everyone wanting to use ReportNG with Maven will be able to achieve it without any problem within a few minutes.

First, the additional dependency has to be added to pom.xml:


Usually in our project a newer TestNG version is used, so that ReportNG dependency should be excluded.

Next, Surefire plugin has to be configured:

                        <value>org.uncommons.reportng.HTMLReporter, org.uncommons.reportng.JUnitXMLReporter</value>

ReportNG uses two reporters pluggable into TestNG. JUnitXMLReporter generates XML summarize of running tests. It’s used for tools (like CI server). HTMLReporter creates human readable HTML report. Default TestNG listeners should be disabled.

After a test run I added also a workingDirectory property which causes that velocity.log (file created by Velocity engine used internally by ReportNG) is placed in a target instead of main project directory (and therefore it is deleted by the “mvn clean” command).

One more thing. Unfortunately ReportNG jar isn’t available in Maven Central Repository, so it could be required to add repository in your settings.xml.


That’s all. Now “mvn clean test” should generate a nice looking HTML report for lots of tests covering our project :).

Update 2012-08-23. This post was written with TestNG 5.x in mind. With TestNG 6.0+ you can meet a problem with “ClassNotFoundException:” exception. In that case Guice dependency needs to be added. Thanks to Alexander Schikora for pointing it out.