ReportNG Report with TestNG is not generated using WebDriver

6.1k views Asked by At

I am using Selenium WebDriver + TestNG with java in Eclipse. I want to generate better report using ReportNG rather than normal TestNG report. I have configured the build path with reportng-1.1.2.jar and velocity-dep-1.4.jar. I have also disabled the default TestNG Report from Project > Properties > TestNG > "Disable Default Listeners" Presently I have created a testNg.xml file that runs my tests as complete Test Suite. The content of xml file is as below:

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite thread-count="5" skipfailedinvocationCounts="false" verbose="1" preserve-order="true" name="testingXML" junit="false" parallel="false" annotations="JDK">
<test verbose="2" name="com.src.com.pcrm.pageobjects.*" junit="false" annotations="JDK">
<testng classpathref="test-path"
            outputdir="${test-results.dir}"
            haltonfailure="true"
            useDefaultListeners="false"
           listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter">
      <xmlfileset dir="." includes="testng.xml"/>
      <sysproperty key="org.uncommons.reportng.title" value="My Test Report"/>
    </testng>
<classes>
<class name="com.pcrm.pageobjects.HomeTest"/>
    <methods>   
        <include name="testManadatoryFieldsOnHomePage"/>
        <include name="testIsLogoDisplayed"/>
        <include name="testUrlCheck"/>
    </methods>

But When I executed this xml file it did not generate any ReportNG reports. What's the wrong? Help is appreciated.

3

There are 3 answers

0
Dan Dyer On

My best guess is that it's a classpath issue. Make certain that the ReportNG and Velocity JARs are on the classpath. See this related question about a similar problem using ReportNG with Selenium.

1
Srinu Thota On

STEP 1 : Download required Jar Files

from here :https://github.com/google/guice you can download below jar file

guice-3.0.jar

from here :http://reportng.uncommons.org/ you can download below jar files

reportng-1.1.4.jar
velocity-dep-1.4.jar

STEP 2 : Add Jar Files In Project's Build path

STEP 3 : Disable default listeners of testng

You need to disable default listeners of testng. To disable default listeners Right click on project folder In eclipse. Go to Properties. - It will open Properties dialog. Go to TestNG and check Disable default listeners--->Apply--->Ok

STEP 4: add these listners in TestNG.xml

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

STEP 5 : Execute test and view ReportNG reports(inside html folder html-->index.html(not outside index.html))

refresh your project folder. It will create/update test-output folder. Explore that folder then explore html folder. You will find index.html file Inside It. To open index.html file.

0
cL83 On

you may try this TestNG-XSLT report, it look greater and easier to read.