TestNG ANT: disable ONLY the html reporter

432 Views Asked by At

I would like to disable ONLY the HTMLReporter in the ANT testng target because it takes 1 minute and I never look at it. This header will run all the default testNG listeners & reporters:

<testng outputdir="${test.output.dir}" verbose="2" haltonfailure="true">

From looking at the documentation I was able to replaces the default listeners&reporters by simply listing the ones I want:

 <testng outputdir="${test.output.dir}" useDefaultListeners="false" 
     listeners="org.testng.reporters.ExitCodeListener, 
     org.testng.reporters.XMLReporter,             
     org.testng.reporters.JUnitReportReporter,
     org.testng.reporters.EmailableReporter,   
     org.testng.reporters.jq.Main,
     org.testng.reporters.VerboseReporter,
     ***org.testng.reporters.TextReporter***" 
   verbose="2" haltonfailure="true">

The problem is that the TextReporter fails to be found! I've checked the jars, it's there, and it does have IResultListener as a parent:

TextReporter extends (TestListenerAdapter implements (IResultListener2 extends IResultListener))

I need the TextReporter to work because it simply prints every simple test method and whether it passed or failed (which I really like).

I'm using TestNG-6.8 (6.9.4 didn't work either). Here's the error:

unit-tests:
   [testng] Exception in thread "main" org.testng.TestNGException:
   [testng] Cannot instantiate class org.testng.reporters.TextReporter
   [testng]     at org.testng.internal.ClassHelper.newInstance(ClassHelper.java:58)
   [testng]     at org.testng.TestNG.setListenerClasses(TestNG.java:686)
   [testng]     at org.testng.TestNG.configure(TestNG.java:1429)
   [testng]     at org.testng.TestNG.privateMain(TestNG.java:1328)
   [testng]     at org.testng.TestNG.main(TestNG.java:1307)
   [testng] Caused by: java.lang.InstantiationException: org.testng.reporters.TextReporter
   [testng]     at java.lang.Class.newInstance(Class.java:359)
   [testng]     at org.testng.internal.ClassHelper.newInstance(ClassHelper.java:49)
   [testng]     ... 4 
1

There are 1 best solutions below

0
On

I've having the same issue, looks like it's unable to instantiate the TextReporter. I went for VerboseReporter instead, it prints the method name, test result and duration.