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.
The plugin also provides a generic API for other unit-test publisher plugins in Jenkins. This functionality was part of the Jenkins Core until it was split out to this plugin in version in 1.577.
The JUnit publisher is configured at the job level by adding a Publish JUnit test result report post build action. The configuration parameters include:
**/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.Skip marking build unstable: If this option is unchecked, then the plugin will mark the build as unstable when it finds at least 1 test failure.
If this option is checked, then the build will still be successful even if there are test failures reported.
In any case, the corresponding pipeline node (and stage) will be marked as unstable in case of test failure.
In order to enable this, set the property:
skipMarkingBuildUnstable
to true
:
junit skipMarkingBuildUnstable: true, testResults: 'test-results.xml'
:warning: This feature requires:
If not disabled in the job configuration, this plugin will publish test results to GitHub through GitHub checks API.
In the Details view of each check (example), test results will be displayed.
In order to disable the checks feature, set the property skipPublishingChecks
to true
:
junit skipPublishingChecks: true, testResults: 'test-results.xml'
The plugin will default to using the stage name or branch of a parallel step prepended by Tests
for the checks name.
If there are no enclosing stages or branches, Tests
will be used. The name can also be overridden by a withChecks
step.
The following snippet would publish three checks with the names Tests / Integration
, Tests
and Integration Tests
, respectively.
stage('Integration') {
junit 'test-results.xml'
}
junit 'more-test-results.xml'
stage('Ignored') {
withChecks('Integration Tests') {
junit 'yet-more-test-results.xml'
}
}
Refer to our contribution guidelines