开发者

Displaying junit fail messages through maven2

开发者 https://www.devze.com 2023-02-12 21:44 出处:网络
I have a Java project that is built through maven2.We use JUnits and occasionally have test failures.I\'m wondering if there is a way to display more information when the test fails.When I run the tes

I have a Java project that is built through maven2. We use JUnits and occasionally have test failures. I'm wondering if there is a way to display more information when the test fails. When I run the tests through Int开发者_开发百科elliJ I get something like "Expected: 3 Actual: 10."

Is there a way to get this same data through maven?


You can configure the maven surefire plugin to output more information on the console using the useFile option.

Your configuration would look like this, then:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <useFile>false</useFile>
  </configuration>
</plugin>

If you need this for specific invocations of your build you can also set this parameter via the command line, like so:

mvn test -Dsurefire.useFile=false


Have you tried: Maven Surefire Report Plugin?

And of course the test results are available in target/surefire-reports, but the format is far from human-readable. Also your CI server should display test failures in a decent format.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号