Reputation: 23
I want to do logging and Test Report Generation with Junit. Logging to a txt file i can achieve using the java logger. To achieve the reporting part, As of Junit 4 there is no such feature. I have heard with Junit 5 it should be possible to generate the test report. Could someone throw some light in to this with their experience of report generation with Junit?
Upvotes: 1
Views: 3758
Reputation: 31177
As I mentioned in How to create an HTML report for JUnit 5 tests?, the JUnit Platform Gradle Plugin and ConsoleLauncher
already generate JUnit 4 style XML reports.
This is done by the XmlReportWriter which is used by the XmlReportsWritingListener. The latter is simply an implementation of TestExecutionListener
.
So, if you want to generate custom reports, you can simply implement your own TestExecutionListener
and take inspiration from the XmlReportWriter
and XmlReportsWritingListener
.
Regards,
Sam (Core JUnit 5 committer)
Upvotes: 1
Reputation: 228
If your project is maven bases, then why not try surefire plugin. doc here - http://maven.apache.org/surefire/maven-surefire-report-plugin/report-mojo.html
Upvotes: 0