danjohnson
danjohnson

Reputation: 80

Displaying junit fail messages through maven2

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 IntelliJ I get something like "Expected: 3 Actual: 10."

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

Upvotes: 2

Views: 656

Answers (2)

Peter Niederwieser
Peter Niederwieser

Reputation: 123940

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

Upvotes: 5

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340793

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.

Upvotes: 0

Related Questions