Search code examples
javamavenseleniumtestngreportng

org.testng.TestNGException:NullPointerException while making a customized reports by reportng


I have recently added this code into my testng.xml

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

I am using the following jar files

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

it is giving me the following error

 org.testng.TestNGException: java.lang.NullPointerException
    at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:341)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.NullPointerException
    at org.testng.xml.TestNGContentHandler.xmlListeners(TestNGContentHandler.java:356)
    at org.testng.xml.TestNGContentHandler.endElement(TestNGContentHandler.java:704)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endNamespaceScope(Unknown Source)

I added the above listener in hope to make customized reports I have added jar files of reportng in the eclipse classpath?

so how can i fix the error?

do I add the the jar files somewhere else?


Solution

  • instead of adding in testng add in ant build.xml

     <testng classpath="class file path" suitename="suite1"
        outputDir="test output"    
        haltonfailure="true"
        useDefaultListeners="false"
        listeners="org.uncommons.reportng.HTMLReporter,org.uncommons.reportng.JUnitXMLReporter"
        >   
            <xmlfileset dir="${ws.home}" includes="testng.xml"/>
            <sysproperty key="org.uncommons.reportng.title" value="Report"/>    
        </testng>
    

    just make sure to keep all the jar files together.