What is ReportNG?
ReportNG is a reporter add-on for TestNG that implements the report listener of TestNG. ReportNG reports provides better user interface(look and feel)compared to the original HTML reports. To generate a ReportNG report we have to add the reporting class to the list of listeners of TestNG while executing the tests. 
Lets implement this in our basic example that we have used in our First Test case with TestNG

Step1:-
Download the required JAR files from :- 
ReportNG+Velocity 
Guice-3.0

Download Guice for ReportNG
Downloading Guice-3.0.zip

Step2:-
Unzip the JAR files and add to the project.
How to add JAR files in Eclipse

Guice-3.0 jar files adding in Eclipse
Adding Guice JAR’s 

Step3:-
Add listener to testng.xml file
listener class-name=”org.uncommons.reportng.HTMLReporter”

JavaCode

XML file:-

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite" >
<listeners>
<listener class-name="org.uncommons.reportng.HTMLReporter"/>
</listeners>
<test name="My first TestNG run using ReportNG">
<classes>
<class name="srcTest.FirstTest"/>
</classes>
</test>
</suite>


Note:-
Incase you are getting the below error,it can be due to missing JAR files in Guice, try adding them again.

java.lang.NoClassDefFoundError: com/google/inject/Module
Code Error 



Step4:-
Observing the results,
test-ouput ->html->index.html

ReportNG results file in Eclipse
index.html
Fancy test results in TestNG using ReportNG
Test Results in ReportNG

Note:– 
We can absorb Reporter.log messages inside output.html

Reporter.log output in ReportNG
Reporter.log messages in ReportNG

Data Parameterization in Selenium using TestNG

Leave a Reply

Your email address will not be published. Required fields are marked *