Skip to end of metadata
Go to start of metadata

Allows JUnit-format test results to be published.

Plugin Information

View JUnit on the plugin site for more information.

Older versions of this plugin may not be safe to use. Please review the following warnings before using an older version:

The JUnit plugin provides a publisher that consumes XML test reports generated during the builds and provides some graphical visualization of the historical test results (see JUnit graph for a sample) as well as a web UI for viewing test reports, tracking failures, and so on. Jenkins understands the JUnit test report XML format (which is also used by TestNG). When this option is configured, Jenkins can provide useful information about test results, such as trends.

This functionality was part of the Jenkins Core until it was split out to this plugin in version in 1.577.

Configuration

The JUnit publisher is configured at the job level by adding a Publish JUnit test result report post build action. The configuration parameters include:

  • Test report XMLs: Specify the path to JUnit XML files in the Ant glob syntax, such as **/build/test-reports/*.xml. Be sure not to include any non-report files into this pattern. You can specify multiple patterns of files separated by commas. The base directory of the fileset is the workspace root.
  • Retain long standard output/error: 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!
  • Health report amplification factor: The amplification factor to apply to test failures when computing the test result contribution to the build health score. The default factor is 1.0. A factor of 0.0 will disable the test result contribution to build health score, and, as an example, a factor of 0.5 means that 10% of tests failing will score 95% health. The factor is persisted with the build results, so changes will only be reflected in new builds.
  • Allow empty results: 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.

Changelog

Version 1.26 (Sep 25 2018)

Version 1.24 (Feb 5 2018)

Version 1.23 (Nov 27 2017)

  • JENKINS-48178 - Set run result in junit step rather than getContext().setResult(...)
  • JENKINS-48196 - Remove redundant parallel branch names from CaseResult display name when appropriate.

Version 1.22.2 (Nov 15 2017)

  • JENKINS-48020 - Get rid of warnings spam in logs and add stage info to failed tests list.

Version 1.22.1 (Nov 14 2017)

  • Fixing junit step on masters without pipeline-stage-step installed.

Version 1.22 (Nov 14 2017)

  • JENKINS-37598 - Fix aggregation issues for multiple files containing cases for the same suite
  • JENKINS-27395 - Distinguish test reports filed in different stages and parallel branches in Pipeline.
  • PR #84 - Prevent unsafe cast to TestResult
  • PR #82 - Enable population of errorDetails for unit testing purposes

Version 1.21 (Aug 4 2017)

  • PR #65: Do not register XMLEntityResolver as a global extension
  • PR #69: Fix a file descriptor leak
  • PR #71: Expose test data publicly
  • PR #77: Improve test results table readability

Version 1.20 (Feb 13 2017)

  • JENKINS-41134 Incorrect reporting of multiple test results in some cases using Pipeline.
  • JENKINS-29736 Incorrect vertical axis values in test duration graph.

Version 1.19 (Oct 17 2016)

  • JENKINS-32148 Highlight test result lines on hover.
  • PR #49 Do not bury 'AllowEmptyResults' configuration option in Advanced.
  • PR #56 Add '<' and '>' as unsafe URI characters.

Version 1.18 (Aug 08 2016; 1.16 & 1.17 were botched)

  • Symbol added in 1.15 did not work in Jenkins 1.x.

Version 1.15 (Jul 12 2016)

  • Integrate Symbol annotation.

Version 1.14 (Jul 5 2016)

  • JENKINS-28784 make TestDataPublisher work in Pipeline.
  • PR #46 Option to cap, or at least log, number of iterations of AbstractTestResultAction.buildDataSet.
  • PR #45 Prevent wrapping for test name table cell.

Version 1.13 (May 1 2016)

Version 1.12 (Apr 20 2016)

  • PR #36 Resolve occurrences of Sonar rule "UselessParenthesesCheck - Useless parentheses around expressions should be removed to prevent any misunderstanding" (see this)
  • PR #35 Testsuite duration may be parsed from time attr.
  • JENKINS-33343 Upgrade to parent POM 2.x

Version 1.11 (Feb 25 2016)

  • Testsuite duration can be retrieved from its time attribute if it exists
  • Remove the glitch symbol in the JUnitResultArchiver configuration

Version 1.10 (Dec 10 2015)

  • (info) JENKINS-12815 Added Job Configuration Option allowing to NOT fail JUnit Report publish when no xml report files
  • (info) PR #23 Remove ambiguity between empty and unreadable files
  • (plus) PR #24 Add API allowing to access passed and skipped tests

Version 1.9 (Sep 3 2015)

  • Export TestActions on the TestObject to make them accessible via the REST API
  • JENKINS-24352 JUnit test result table wrapping duration text

Version 1.8 (Jul 29 2015)

  • JENKINS-29613 Failure summary jumps to the top of the page when expanded/collapsed.

Version 1.7 (Jul 17 2015)

Version 1.6 (May 01 2015)

  • JENKINS-26077 Duplicated result links when using the xUnit plugin.
  • JENKINS-27974 Unusable URL produced when classname field in results was empty.

Version 1.5 (Mar 11 2015)

  • Trim stdio even on failing tests, just to a 100× larger cutoff.
  • Diagnostics for an infinite loop.
  • Corrected help text.
  • Japanese translation edits.

Version 1.4 (Feb 04 2015)

  • NPE not known to affect actual usage but blocking tests of JENKINS-25446.

Version 1.3 (Dec 03 2014) (requires 1.580.1+)

  • JENKINS-25573 Health score factor did not work.
  • Repeated archiving fix in 1.2-beta-2 did not work on slaves.
  • JENKINS-24580 Older and newer links were swapped in the display.

Version 1.2 (Nov 06 2014)

Version 1.2-beta-4 (Nov 04 2014)

  • JENKINS-25375 Restore deprecated method override for binary compatibility.

Version 1.2-beta-3 (Oct 25 2014)

Version 1.2-beta-2 (Oct 20 2014)

  • Permit the archive step to be run multiple times on the same build, aggregating results. (Applicable from workflows, not from normal usage as a publisher in a freestyle project.)
  • Some configuration fields could not be set in 1.2-beta-1.
  • Typos in some text, and German localization fixes.
  • Do not show form validation errors when used from a non-freestyle context.
  • Ignore a noisy AccessDeniedException when listing jobs.

Version 1.2-beta-1 (Aug 25 2014)

Version 1.1 (Aug 25 2014)

  • Marked as dependent on 1.577, so 1.575/1.576 users should not install it.

Version 1.0 (Aug 11 2014)

Initial version after split.

31 Comments

  1. Hi,

    I would like to request to have a checkbox for allowing missing reports. Some of my projects do not have unit tests and are not planing to.

    However due to the limitation of this plugin, I cannot use it on those projects.

    I had to revert back to use html publisher to publish my test reports in order to allow the build to pass.

    Removing the plugin on the projects that do not require unit test is a no go for me as well since we are using templates with Jenkins Job Builder.

    Having different template for projects with and without unit tests would be harder to maintain.

    Regards,

    Michael Loo

    1. Two of us worked out pretty much identical solutions. This was merged in from Pull Request #28.  It will propagate soon, as testing proceeds.

  2. We have multiple JUnit XML files that we would like to display separate graphs for rather than having them aggregated into one. Is this possible, could you add this feature?

  3. Hi,

    In my current hudson configuration Test Result Trends showing as below graph (x-axis:Build ID and y-axis:Count of test cases).

    Now I have a requirement where in x-axis should have Build-date. For this where I need to the change?

    Please someone help in this

  4. Hi,

    We re using junit plugin for publishing xml reports for our test jobs. Do we have any option to give variable in TestReportXML's instead of giving relative path/ full path. We have a jenkins variable where we define the path we want publish the report in that path instead of harcoding it.

    Kalyan

  5. I get errors related to JUnit in the log for the latest version JUnit 1.9 with jenkins 1.629 :java.lang.NoClassDefFoundError: hudson/maven/MavenBuild
    at org.jenkinsci.plugins.junitrealtimetestreporter.RealtimeTestResultAction.getProject(RealtimeTestResultAction.java:190)
    at org.jenkinsci.plugins.junitrealtimetestreporter.RealtimeTestResultAction.getConfig(RealtimeTestResultAction.java:198)
    at org.jenkinsci.plugins.junitrealtimetestreporter.Attacher.isApplicable(Attacher.java:61)
    at org.jenkinsci.plugins.junitrealtimetestreporter.Attacher.onStarted(Attacher.java:46)
    at hudson.model.listeners.RunListener.fireStarted(RunListener.java:215)
    at hudson.model.Run.execute(Run.java:1737)
    at com.tikal.jenkins.plugins.multijob.MultiJobBuild.run(MultiJobBuild.java:73)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:408)
    Caused by: java.lang.ClassNotFoundException: hudson.maven.MavenBuild
    at jenkins.util.AntClassLoader.findClassInComponents(AntClassLoader.java:1376)
    at jenkins.util.AntClassLoader.findClass(AntClassLoader.java:1326)
    at jenkins.util.AntClassLoader.loadClass(AntClassLoader.java:1079)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 9 more

    I think it might be related to a problem I'm having where my builds can't be read from disk anymore

    1. Chris,

      I've re-opened an issue on this.  Please check out Jira Issue JENKINS-22747 and vote it up.

  6. Hi,
    Could I receive some average estimate on the complexity of the following feature (and any starting point for development): we need to publish multiple reports filtered by package/class names.
    The reason is - many teams own different packages from the automation tests and currently we have multiple jenkins jobs (above 15) for the different teams so to have separate reports.
    We are willing to offer assistance (under guidance) for adding this feature.

    Regards,
    Nikki

  7. The "Publish JUnit test result report" Post-build step still fails if there are no generated JUnit xml output files.

    ERROR: Publisher hudson.tasks.junit.JUnitResultArchiver aborted due to exception
    hudson.AbortException: No test report files were found. Configuration error?
    

    Can a configuration be added to make this failure optional?  The Cobertura Reporting plugin does this.

    Re-opened Issue JENKINS-22747 to track this

  8. Hi all,

    I have a request/suggestion to extend the test analysis logging capabilities of jenkins. 

    I have a jenkins job which runs tests on a daily basis (and publishes jUnit reports for them). A lot of these tests are failing; for most of them, the fix for the issue is out of our control (needs to be provided by a third party), which is why they've been failing for quite some time.
    Most of these failures were analysed at the time they occurred for the first time. However, since that's been a while ago, we tend to forget what the analysis was (if any, since some failures are still not analyzed yet).
    This means we have to repeat the analysis work, which is wasted effort.
    I know jenkins allows you to go back to the first time the failure occurred, and check if there's a "description" provided for the test in that run, but that approach feels cumbersome when iterating over multiple failures.

    So it would seem really nice to me if there was an overview in which we could persistently document a failing test, to make it clear it has been analysed, and what the analysis is.
    E.g, on the 'test results' page, there's a table for the failed tests, listing test name, duration, and age. Maybe a "failure analysis" column could be added there? If a test is failing (as reported by junit), jenkins could check if the test was also failing in the previous build, and if it was, copy the text in the "failure analysis" field. The user would have the option to manually populate/overwrite this field (serving as info for users, as well as for future runs).

    I'm wondering if other users have felt the need for similar functionality, and/or if such a plugin exists already (I searched for about 1h, but couldn't find one)?

  9. Hi all,

    I have a request/suggestion to extend the test analysis logging capabilities of jenkins. 

    I have a jenkins job which runs tests on a daily basis (and publishes jUnit reports for them). A lot of these tests are failing; for most of them, the fix for the issue is out of our control (needs to be provided by a third party), which is why they've been failing for quite some time.
    Most of these failures were analysed at the time they occurred for the first time. However, since that's been a while ago, we tend to forget what the analysis was (if any, since some failures are still not analyzed yet).
    This means we have to repeat the analysis work, which is wasted effort.
    I know jenkins allows you to go back to the first time the failure occurred, and check if there's a "description" provided for the test in that run, but that approach feels cumbersome when iterating over multiple failures.

    So it would seem really nice to me if there was an overview in which we could persistently document a failing test, to make it clear it has been analysed, and what the analysis is.
    E.g, on the 'test results' page, there's a table for the failed tests, listing test name, duration, and age. Maybe a "failure analysis" column could be added there? If a test is failing (as reported by junit), jenkins could check if the test was also failing in the previous build, and if it was, copy the text in the "failure analysis" field. The user would have the option to manually populate/overwrite this field (serving as info for users, as well as for future runs).

    I'm wondering if other users have felt the need for similar functionality, and/or if such a plugin exists already (I searched for about 1h, but couldn't find one)?

  10. Hello,

    I am running Jenkins on one server which needs to be taken away, so I need to move Jenkins on another server. Jenkins folder is on a shared drive, so I am able to run it from the new server without problems. Also, the records folder for the jenkins jobs is now shared hence I can see all the jobs / builds I've run in the past from the new server instance. However, Jenkins doesn't show the test results graph in the Job's main page. I have all the runs, I can select any of them and see its test results, but I don't see the graph in the home page.

    Is there a way to make Jenkins JUnit plug-in regenerate the data to show the graph from those builds? Or does the plug-in save the information to generate the graph somewhere on the local machine where the server runs?

    Thanks

    Best Regards

    Ferruccio

    1. I'm seeing the same issue, we have projects that Publish jUnit results and display the graph and others that don't. I've reviewed the configs for both and haven't found any obvious differences.

      1. For me it was caused by always having failing builds https://issues.jenkins-ci.org/browse/JENKINS-40103, one I had a successful build, the trend chart appeared.

  11. Hi, 

    Thanks for this great plugin!!

    I am using xUnit plugin and JUnit component.
    I can see multiple "Latest Test Result" links,along with Multiple "Test Result Trendgraphs.
    Also,the graphs have no data,where as the test cases data can be seen by clicking on the "Latest Test Result" link.
    Also,the "Test Result Trend" has always the latest build number only and is always empty.

    I am assigning build number to my jobs via a groovy script(so that all my jobs can share unique build numbers across jenkins),and I feel the same causes the graphs to have the only the latest build number,and thus the blank "Test Result Trend" graph.
    The Test results however can be easily used/consumed by other plugins like "tests results analyser"

  12. Hello:

    I have a couple of questions about the Junit plugin.

    1. Can I enable it to read customs test results like "Ignored", "Pending" that I want to define
    2. Once, read, will I be able to parse and plot those result types in a junit graph?
    3. Is there a way for the junit plugin to be a little more smart about tracking the result trend of test cases by name rather than count. For eg. In build 1 I have tc-01, tc-02 passed, in build 2, i have tc-02 and tc-03 (newly added) pass but tc-01 fail. I want the graph to incrementally stack newly discovered test cases.

    Can this or other plugins do this, if not what are my options

    1. Hi all:

      Any ideas on the above?

      Regards

      Ani

  13. Hi,

    We are facing a problem with Angular with Karma Project build automation using jenkins. Following are the steps.

    1. Unit Testing using Karma with Jasmine
    2. When All the specs in Karma is success then only the project will build and deploy
    3. When one spec is failure then it will stop the the build.

    Kindly help to solve the issue.

    Thanks,

    Jivesh

  14. Hi,

    Currently Build step 'Publish JUnit test result report' changes build result to UNSTABLE (there is a failed test) with the next options:

    • Health report amplification factor = 0.0
    • Allow empty results

    How can I disable updating build results by the plugin?

    Thanks in advance!

  15. Hi,

    We're having a weird behavior wherein the entire standard output of a test class appears in every test fail page. Is this expected?

     

  16. Hi, 

    We have the Junit reporting setup to read from our XML file. The order of our XML is being modified by this plug in! The tests usually have a suffix which is the order they are performed in. (e.g. test_checkbox_001 , test_boxIsNowOpen_002).

    We have the same order in our XML file, but the parser for this tool will somehow parse and display the results rearranged. Is there a way to over-write the default ordering of the tests the results are displayed in? 

    Please advise,

    Thanks

  17. Hi,

    When can i download "FailureAnalysisPlugin" to analyze test results for JUnits ?

    Thanks,

    Rajesh

     

  18. Hi,

    I am using junit plugin to publish my result. Junit marks the build as unstable in case of failures. But for my use case I want to mark the build as failed. For that I am using healthScaleFactor=100. But that doesn't work.

    Any thoughts? Thanks.

    1. And I am not sure why my name shows as "IRCbot run by Kohsuke"!

      1. Wow I have the same problem...

  19. Can anyone tell me how to publish multiple JUNIT reports via multiple xml files.

    right now i have multiple xml files and want to publish different JUNIT report for those.

    please let  me know if that is possible.

  20. Is there a way to exclude some folders from the junit glob pattern? I really need to convince the plugin not to look into some symlinked folders as it would duplicate collection.

  21. Hi,

    Any idea why when test results are recorded from scripted pipelines , Graph is not shown? Is there way to fix this ?

    Below is my code snippet,

    stage('Post'){

    step([$class: 'JUnitResultArchiver', testResults: 'nosetests.xml' ])

    }

    In the logs it shows test results are recorded, also shown in build summary.

  22. Hi,

    Sometimes,test results show ‘no failures’, but it really has one failure. I don't know why this happened.

  23. Hi,

     

    I want to install JUnit v1.21. Do you know where I can get the install package?

     

    Thanks!

    -Maggie

  24. Can it be made that if the results file is missing the overall status for the test being run is a failure?  I realise that there is Allow empty results but that shouldn't mask a test run that fails so badly that it doesn't even produce a results file.