Using ReportNg with Selenium WebDriver



ReportNG is a simple HTML reporting plug-in for the TestNG
Why ReportNG?

The ReportNG implementation maps each test class to a single <testsuite> element, resulting in one XML file per test class. This is different from the approach taken by the core TestNG implementation.




What we need?
To Start working with ReportNG , we need to download reportng-1.1.4 and velocity-dep-1.1.4 jar files which are latest versions till date.









What Next?
Add the above mentioned libraries to your Selenium +TestNg Project's build path.
We need create testng.xml file which looks like

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite" parallel="none">
 <listeners>
     <listener class-name="org.uncommons.reportng.HTMLReporter"/>
 </listeners>
  <test name="SmokeTest">
      <classes>
      <class name="reportng.FirstTest"></class>
      <class name="reportng.SecondTest"></class>
      </classes>
     
  </test>
</suite>
Run the testng.xml file as "Run As -->TestNG Suite"
What If?
You come across an error which looks like

Fix it by 
  • Right Click on project->TestNG->Check the checkbox "Disable default Listeners"
  • Downloading guice-3.0 and adding it to the build path your project
That is it !!You are good to Run the testng.xml file and check out the report generated.

Comments

Popular posts from this blog

Cypress Cheat Sheet

Selenium WebDriver-Working with Listbox and Multi-Select Listbox

Selenium WebDriver -Handling JavaScript alerts