How to keep the unit test output in Jenkins

后端 未结 5 1446
谎友^
谎友^ 2021-01-02 12:01

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, dire

相关标签:
5条回答
  • 2021-01-02 12:17

    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.

    0 讨论(0)
  • 2021-01-02 12:18

    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.

    0 讨论(0)
  • 2021-01-02 12:22

    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

    0 讨论(0)
  • 2021-01-02 12:22

    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

    0 讨论(0)
  • 2021-01-02 12:31

    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.

    0 讨论(0)
提交回复
热议问题