How to use ReportNG with TestNG for HTML Reporting

ReportNG is Open Source software, free to download and use subject to the terms of the Apache Software Licence, Version 2.0. 

ReportNG is a simple HTML reporting plug-in for the TestNGunit-testing framework. It is intended as a replacement for the default TestNG HTML report. The default report is comprehensive but is not so easy to understand at-a-glance. ReportNG provides a simple, colour-coded view of the test results. 

ReportNG generates 100% valid XHTML 1.0 files. The output can be customised by over-riding the default stylesheet with your own CSS file.

In this article we will learn how to integrate ReportNG with TestNG.

A. Before we start integrating ReportNG you will need three libraries as follows.

  1. reportng-1.1.4.jar
  2. velocity-dep-1.4.jar
  3. guice-3.0.jar
You have two options -
  1. Either download above three libraries and add manually to your class-path (in your eclipse or whatever IDE you will be using for your testing).
  2. Or add dependencies in Maven "pom.xml" file as shown below and build the project. I am not going to explain how maven works... I am assuming that whoever will be using 2nd option would know maven (this is the recommend option).

B. Next important step is to set the listeners attribute of the testng element. The class names for the ReportNG reporters are:


In your testng.xml file, please add following lines as shown in below screenshot.
          <listener class-name="org.uncommons.reportng.HTMLReporter" />
          <listener class-name="org.uncommons.reportng.JUnitXMLReporter" />
Final testng.xml will look like below -

C. Next important step is to disable default TestNG report listeners by setting the useDefaultListeners attribute to "false"so that when you will run test next time, it will not generate default testng report.

You can also disable default listeners from eclipse. Steps are mentioned below -

  1. In your project, right click and select "Properties"
  2. Click on TestNG from left side options.
  3. You will find a checkbox called "Disable default listeners", select that check box 
  4. Specify the report folder name (otherwise default Report folder name will be "test-output".
  5. Save changes by clicking on "Apply" button.

D. Now when you will run test, you will find one new folder under above "Report" directory called "html" which will have your final ReportNG html report as shown below.

  • Html report location:

  • Sample ReportNG report overview:

Please let me know if you have any comments or questions. Happy automating....!!
Related Posts Plugin for WordPress, Blogger...
Powered by Blogger