4

I heard that ReportNG creates a better report than TestNG's normal report. I tried to create ReportNG report, but failed. I am using Eclipse and I have downloaded ReportNG and added reportng-1.1.3.jar and velocity-dep-1.4.jar into classpath and written testng-suite.xml as below:

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

when I executed I could see the TestNG default report rather than ReportNG report. What else should I do to get ReportNG's report (like extend any class or implement listeners or write snippet of code)?

Also I heard that I have to use the command, useDefaultListeners="false" , but where should I include in the testng-suite.xml? Everyone is telling about ANT but I don't personally like it to use. So is there any way to include the above command into testng-suite.xml?

Ripon Al Wasim
  • 36,924
  • 42
  • 155
  • 176
Unni
  • 147
  • 5
  • 16

3 Answers3

3

I am the author of ReportNG. You don't need to write any Java code to get it to work. You just need to be able to register listeners with TestNG from whichever tool you use.

I've only used ReportNG from Ant but other people have got it working with other build systems such as Maven and Gradle. I don't know if there is anything Selenium-specific that would prevent it from working. Are you getting any error messages? The first thing I would check is to make sure that the ReportNG JAR is on the classpath.

I didn't even realise that you could specify TestNG listeners in the testng.xml file. However, I have just modified my sample reports to specify the listeners in this way rather than in the Ant build file and it works fine, so the problem is probably in the way you are configuring TestNG from Selenium.

Dan Dyer
  • 53,737
  • 19
  • 129
  • 165
  • Yes, even i read no code is required to get the report. We have to add jars in the classpath and put the listeners code in the suite.xml.. I have done the same but no report from ReportNG. Meanwhile jars are rightly built along with other many jars including testng, selenium server, selenium java etc. If jars are not build then system should throw the runtime error since we have included code. It run well without any error but no report – Unni Jun 17 '11 at 06:17
  • Hi @Dan Dyer. The problem that I'm facing is that test results of `ReportNG` and `TestNg` are different. TestNG says 8 Pass, 2 Fails and according to ReportNG 1 Fail 9 Skip. How's that possible. – Sanchit Oct 25 '17 at 01:21
  • @Sanchit I don't know off the top of my head (maybe something changed in a recent version of TestNG?). I'm no longer using TestNG day-to-day and therefore haven't been maintaining ReportNG for a while. It should be considered abandonware at this point. You're free to fork it and do as you want with it but unfortunately I don't have the time to investigate issues with it. I appreciate this isn't very helpful, sorry. – Dan Dyer Oct 25 '17 at 13:01
  • @DanDyer Appreciate your reply. I've raised a question on this as well. If you wish you can have a look at the below mentioned link. Since all details are written there, it might help you.https://stackoverflow.com/questions/46923243/selenium-java-maven-project-testng-results-differs-from-reportng – Sanchit Oct 26 '17 at 01:04
3

How are you launching from Eclipse? You should be right-clicking on that XML file and select "Run as... TestNG suite". I'm assuming that's what you're doing.

Using default listeners should not have any impact on the problem you are seeing, I am guessing that some people use this because if they use ReportNG, they don't care about any of the other listeners that TestNG generates. Having said that, if you ever want to do this from Eclipse, you can simply edit the launch configuration that was created when you launched your suite as indicated above and add "-usedefaultlisteners false" to the parameters box.

Cedric Beust
  • 15,480
  • 2
  • 55
  • 55
  • Yes am launching 'Run As TestNG suite'. I am ok even if the default listeners are getting created, but i should get ReportNG result. Between can u please explain where in the configuration i have to include "-usedefaultlisteners false" ?. I have only a suite.xml and i have written as i said in this post. – Unni Jun 17 '11 at 06:09
3

To disable defaultlisteners ,

Goto Eclipse Project-> Properties -> TestNG -> Disable deafult listeners.

After running you will end up with following error:

java.lang.NoClassDefFoundError: com/google/inject/Module 
        at java.lang.Class.getDeclaredMethods0(Native Method) 
        at java.lang.Class.privateGetDeclaredMethods(Unknown Source) 
        at java.lang.Class.privateGetPublicMethods(Unknown Source) 
        at java.lang.Class.getMethods(Unknown Source) 

to solve this, download google-guice-3.0.zip and paste guice-3.0.jar into your classpath.

Now run and check the report in workspace/test-output/html.

Naman
  • 27,789
  • 26
  • 218
  • 353
Unni
  • 147
  • 5
  • 16