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?
Retrieve standard output of successful tests in surefire?
Yes. You can redirect the output of your tests to a file with this optional parameter:
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
Thanks, that one I have tried already - it however does not work for me - the output in testName-output.txt is empty after test terminates. I can see the output file growing and containing the output while test is running, however after the test case execution terminates, the file is truncated down to 0 bytes and the output is lost. Any thoughts? –
Felicity
That's a little odd. Is anything else overwriting that property setting? Do you see any errors if you run with verbose output switching on? Do you have the "useFile" property switched off by any chance? –
Modestine
it does not work for me, intellij complain with element not allowed here –
Downall
© 2022 - 2024 — McMap. All rights reserved.