Possible bugs with reporter handling

289 views
Skip to first unread message

Christian Mötzing

unread,
Oct 6, 2014, 8:55:56 AM10/6/14
to testn...@googlegroups.com
Hi, I attached a simple project. I was trying to disable default listener and re-enable two of the default listener a.k.a. reporter. The documentation mentions a property -reporter (analogous to -listener). For me this flag is not working. Any reporter set here is silently ignored ('mvn -f pom.xml clean test' in test project). I am calling testng through maven-surefire-plugin but that should not change what is documented here, right? http://testng.org/doc/documentation-main.html (Chapter 4 - Running TestNG).

Second thing is if I set the reporter as listener it gets called but does not work:

java.io.FileNotFoundException: D:\mbc\testng-bug\.\target\surefire-reports\testng-results.xml (The system cannot find the path specified.)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:205)
        at java.io.FileOutputStream.<init>(FileOutputStream.java:156)
        at java.io.FileWriter.<init>(FileWriter.java:84)
        at org.testng.internal.Utils.writeUtf8File(Utils.java:107)
        at org.testng.reporters.XMLReporter.generateReport(XMLReporter.java:66)
        at org.testng.TestNG.generateReports(TestNG.java:1115)
        at org.testng.TestNG.run(TestNG.java:1074)
        at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:115)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.executeSingleClass(TestNGDirectoryTestSuite.java:128)
        at org.apache.maven.surefire.testng.TestNGDirectoryTestSuite.execute(TestNGDirectoryTestSuite.java:112)
        at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:112)
        at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

Execute 'mvn -f pom-2.xml clean test' in test project to reproduce. Same for the SuiteHTMLReporter, it can not find testng.css.

Thx in advance

Christian
testng-bug.zip

Christian Mötzing

unread,
Oct 13, 2014, 6:22:50 AM10/13/14
to testn...@googlegroups.com
Can anyone confirm this behaviour or point out a mistake I made? 
Or should I just file a bug report?

Christian Mötzing

unread,
Oct 13, 2014, 8:10:40 AM10/13/14
to testn...@googlegroups.com
It looks like the reporters do NOT create the output directory if it does not exist.

public class HtmlAndXmlReporter implements IReporter {

    private final XMLReporter xmlReporter = new XMLReporter();

    @Override
   public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
       File dir = new File(outputDirectory);
       if (!dir.exists()) {
           dir.mkdirs();
       }
       xmlReporter.setOutputDirectory(outputDirectory);
       xmlReporter.generateReport(xmlSuites, suites, outputDirectory);
   }
}

This works for me. Not sure where the folder gets create with default listeners enbaled though.



Am Montag, 6. Oktober 2014 13:55:56 UTC+1 schrieb Christian Mötzing:
Reply all
Reply to author
Forward
0 new messages