Hynek
Hynek

Reputation: 189

Retrieve standard output of successful tests in surefire?

Maven Surefire records standard output and error output for every failed tests which can be later found in generated files in surefire-reports directory. The output of tests which pass with no error is however discarded. Is it possible to set up surefire to record the stdout/stderr also for tests which successfully pass?

Upvotes: 6

Views: 4454

Answers (1)

serg10
serg10

Reputation: 32667

Yes. You can redirect the output of your tests to a file with this optional parameter:

redirectTestOutputToFile

It's defaulted to false. If you switch it on with:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <redirectTestOutputToFile>true</redirectTestOutputToFile>
  </configuration>
</plugin>

Your unit test output will be written to reportsDirectory/testName-output.txt

Upvotes: 6

Related Questions