问题
When I run the tests In my Java/Groovy Maven project, the test reports are stored in target/surefire-reports
. For each test class that is run a .txt
and .xml
file is created showing the output of that class.
All in all, this is a remarkably unhelpful format, as it doesn't provide any easy way to quickly see which tests failed and the output they produced. I'd like something similar to Grails' test reports. Is there are any easy way to change the report format to something more user friendly?
Ideally, I'd like this report to be generated when I run mvn test
, i.e. I'd prefer not to have to run mvn site
to generate it.
回答1:
I am using the Maven Surefire Report plugin to generating the unit testing report. The web site is http://maven.apache.org/plugins/maven-surefire-report-plugin
My POM looks like the following: -
<reporting>
<plugins>
....
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.9</version>
</plugin>
</plugins>
</reporting>
I hope this may help to achieve your requirement.
//Edit: I also use the CI server, the Jenkins, which provides the unit testing report as well.
Regards,
Charlee Ch.
回答2:
Sort the folder by size in ascending order. Biggest .txt
files are the output of failed tests.
回答3:
There is an HTML report plugin (here), but not sure this is what you want. If you need something more specific, I guess you'll need to develop your own Maven plugin.
来源:https://stackoverflow.com/questions/6503895/maven-test-report-format