Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep the unit test output in Jenkins

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?

like image 812
striker69 Avatar asked Aug 04 '11 16:08

striker69


4 Answers

In the Publish JUnit test result report (Post-build Actions) tick the Retain long standard output/error checkbox.

If checked, any standard output or error from a test suite will be retained in the test results after the build completes. (This refers only to additional messages printed to console, not to a failure stack trace.) Such output is always kept if the test failed, but by default lengthy output from passing tests is truncated to save space. Check this option if you need to see every log message from even passing tests, but beware that Jenkins's memory consumption can substantially increase as a result, even if you never look at the test results!

enter image description here

like image 93
R. Oosterholt Avatar answered Oct 11 '22 07:10

R. Oosterholt


This is simple to do - just ensure that the output file is included in the list of artifacts for that job and it will be archived according to the configuration for that job.

like image 32
the_mandrill Avatar answered Oct 11 '22 09:10

the_mandrill


Not sure if you have solve it yet, but I just did something similar using Android and Jenkins.

What I did was using the http://code.google.com/p/the-missing-android-xml-junit-test-runner/ to run the tests in the Android emulator. This will create the necessary JUnit formatted XML files, on the emulator file system.

Afterwards, simply use 'adb pull' to copy the file over, and configure the Jenkin to parse the results. You can also artifact the XML files if necessary.

If you simply want to display the content of the result in the log, you can use 'Execute Shell' command to print it out to the console, where it will be captured in the log file.

like image 28
Charles Avatar answered Oct 11 '22 09:10

Charles


Since Jenkins 1.386 there was a change mentioned to Retain long standard output/error in each build configuration. So you just have to check the checkbox in the post-build actions.

http://hudson-ci.org/changelog.html#v1.386

like image 23
Stephan Avatar answered Oct 11 '22 08:10

Stephan