ReportNG with TestNG

We will see, How can we integrate the ReportNG with TestNG. As we have seen TestNG has very nice HTML reporting features. We have seen, how do we get the HTML report in test-output directory.

TestNG generates the default report in test-output directory.

To see the TestNG HTML report after test execution, you need to refresh your project ( Select your Project and press F5).

You will notice that test-output directory is been created in your project.

 

Open this directory in your local and click on the index.html to view the detailed execution report. We have discussed this in Sample Test using TestNG tutorial.

 

Video Tutorial:

If you liked this video, then please subscribe to our YouTube Channel for more video tutorials.

 

ReportNG Integration with TestNG

ReportNG is a plug-in, Which we can use with TestNG testing framework to generate HTML reports as a replacement for the default TestNG HTML reports.

Let’s see how we can configure the ReportNG with TestNG.

  1. Download the ReportNG Jar files. (Download from here!)
  2. Click on the “Download” link on the reportNG page.
    Download ReportNG
  3. You will get the zip folder from this link. Unzip this folder in your local machine. You will find the two jar files inside this folder named ReportNG and Velocity-dep.
  4. We need one more jar file, Google Juice Core jar file (Download from here!) .
    Download Google Juice Jar

5. Keep all these Jar files in your local directory.

6. Add these jars to your project. (Right Click Project -> Build path-> Configure Build path -> Add External Jars)
After addition, these files looks like.
Add Jar in Eclipse

7. To generate Report NG reports we need to disable TestNG default listeners.
To disable TestNG listeners follow the below-mentioned steps-

A. Right Click your project and Select “Properties”.

B. In the List, click on the option “TestNG”.

C. Check the checkbox “Disable default listeners”.

D. Click on “Apply” and click on “Ok” button.

Disable TestNG Listeners

8. Now we need to modify “test.xml”. We need to add two listeners in our suite.

<listeners>
      <listener class-name=”org.uncommons.reportng.HTMLReporter”/>
      <listener class-name=”org.uncommons.reportng.JUnitXMLReporter”/>
  </listeners>

 

So Finally we have configured ReportNG in our project successfully. Now let’s see how we can generate the Enhance HTML reports using ReportNG.

 

Now we have two Test Classes, SampleTest and TestExecutionOrder class.

 

 

So we have created our Test Classes, Now we need to configure our testng.xml file. Let’s see the example of testng.xml file for these files.

<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd” >
  
<suite name=”SampleSuite” >

  <listeners>
      <listener class-name=”org.uncommons.reportng.HTMLReporter”/>
      <listener class-name=”org.uncommons.reportng.JUnitXMLReporter”/>
  </listeners>

 

  <test name=”First Test” >
    <classes>
       <class name=”com.Seleniumbix.TestNG.SampleTest” />
    </classes>
  </test>
 
  <test name=”Second Test”>
    <classes>
      <class name=”com.Seleniumbix.TestNG.TestExecutionOrder”/>
    </classes>
  </test>
</suite>

 

Now we will execute our testng.xml file. Execute your Suite and refresh your project. Have you noticed we have a new folder in out “test-output” directory named “HTML”.

Now we will see what’s the difference between default and ReportNG HTML report.

1. Default TestNG Report – We have seen default report earlier, Let’s see it again. Open test   output directory on your local machine and click on the “index.html”. Reports look like –

TestNG Report

 

2. ReportNG Test Report – To see the ReportNG report, Open the “test-output” directory, In this directory open the “HTML” directory and click on the “index.html” .

Congrats, you have done. It enhances ReportNG HTML file. Let’s see the snap of ReportNG report of our Test suite in TestNG.

ReportNG

 

Have you seen, this is the featured report? Here we are getting Test Results and pass-fail percentage as well.

To see the Test specific result, you need to click on that particular Test Case in Test report. Let’s click on our Second Test descriptive result.

 

ReportNG Report

 

0 Comment

Leave a Reply