How to keep the unit test output in Jenkins

Viewed 16441

We have managed to have Jenkins correctly parse our XML output from our tests and also included the error information, when there is one. So that it is possible to see, directly in the TestCase in Jenkins the error that occurred.

What we would like to do is to have Jenkins keep a log output, which is basically the console output, associated with each case. This would enable anyone to see the actual console output of each test case, failed or not.

I haven't seen a way to do this.

* EDIT *

Clarification - I want to be able to see the actual test output directly in the Jenkins interface, the same way it does when there is an error, but for the whole output. I don't want only Jenkins to keep the file as artifact.

* END OF EDIT *

Anyone can help us on this?

5 Answers

When using a declarative pipeline, you can do it like so:

junit testResults: '**/build/test-results/*/*.xml', keepLongStdio: true

See the documentation:

If checked, the default behavior of failing a build on missing test result files or empty test results is changed to not affect the status of the build. Please note that this setting make it harder to spot misconfigured jobs or build failures where the test tool does not exit with an error code when not producing test report files.

Related