Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit output in Maven reports

I am using Maven for my project and have following question:

I want to see the logging output of my JUnit tests (log4j, System.out, whatever) in test reports. Do you have any idea how to achieve this?

Thanks ;-)

like image 432
crypto5 Avatar asked Jan 08 '10 19:01

crypto5


People also ask

Can we generate reports using JUnit?

By default, JUnit tests generate simple report XML files for its test execution. These XML files can then be used to generate any custom reports as per the testing requirement. We can also generate HTML reports using the XML files.

How do I customize a JUnit report?

The junitreport task uses XSLT to produce the report from the XML files generated by the junit task. For customizing the the output, one option would be to make a copy of the default XSLT and modify that. Or you could look for an alternative XSLT which is more easy to customize for your purposes.


1 Answers

I believe you can redirect the output (System.out) of test using the maven surefire plugin configuration key redirectTestOutputToFile, and then find the output in target/surefire-reports

Check more about this in the plugin docs

In one snipplet:

<build>
  <plugins>
      <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
          <redirectTestOutputToFile>true</redirectTestOutputToFile>
      </configuration>
      </plugin>
  </plugins>
</build>
like image 184
YuppieNetworking Avatar answered Sep 21 '22 15:09

YuppieNetworking