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 ;-)
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With