View tests
View the results from CI tests.
Your CI pipelines can run tests in Run steps and Test steps. In Harness, test results can be published to the Build details page on either the Tests tab or the Artifacts tab.
Publish reports to the Tests tab
To publish test results and view them in Harness, you must produce test reports in JUnit XML format and add the Report Paths specification to the step, for example:
- step:
type: Run
name: Tests
identifier: tests
...
reports:
type: JUnit
spec:
paths:
- /path/to/test/report.xmlThe Tests tab displays test results from reports in JUnit XML or TRX format (TRX reports are automatically converted to JUnit XML). For information about formatting unit test reports, go to Format test reports.
After a build runs, you can review test reports on the Tests tab on the Build details page. The content differs for Run and Test steps.
Results from Run steps
If you used a Run step, the Tests tab contains information about the total number of tests, the failure rate, and a list of failed tests. You can hover over individual failed test to view additional details about the failure.
If you ran tests in multiple steps/stages, or parallel steps/stages, use the Step/Stage dropdown menu to switch between reports from different steps or stages.
Results from Test steps with Test Intelligence
If you are using Test Intelligence for your unit tests, the Tests tab contains information unique to Test Intelligence. In addition to the test results, you can also get information about which tests were selected by Test Intelligence and why Test Intelligence selected those tests.
Expand the sections below to learn more about the information available on the Tests tab for Test Intelligence.
View reports on the Artifacts tab
For reports that can't be published to the Tests tab, you can use the Artifact Metadata Publisher plugin to publish reports to the Artifacts tab on the Build details page. You can publish any URL to the Artifacts tab.
To publish a test report to the Artifacts tab, you must:
Include steps in your pipeline that run tests and produce test reports.
Add a step to upload the report artifact to cloud storage, such as:
Add a Plugin step that uses the
artifact-metadata-publisherplugin, configured as follows:Name: Enter a name.
Container Registry: Select a Docker connector.
Image: Enter
plugins/artifact-metadata-publisher.Settings: Add the following two settings as key-value pairs:
file_urls: Provide the URL to the artifact that was uploaded in the Upload Artifacts step. If you uploaded multiple artifacts, you can provide a list of URLs.artifact_file: Provide any.txtfile name, such asartifact.txtorurl.txt. This is a required setting that Harness uses to store the artifact URL and display it on the Artifacts tab. This value is not the name of your uploaded artifact, and it has no relationship to the artifact object itself.
Include steps in your pipeline that run tests and produce test reports.
Add a step to upload the report artifact to cloud storage, such as:
Add a Plugin step that uses the
artifact-metadata-publisherplugin, for example:
Parse JUnit tests results
The parse-test-reports plugin is a Harness plugin designed to parse JUnit XML test reports and fail the pipeline if any test failures are detected. This plugin ensures that the entire test suite runs, even if failures occur, by deferring the detection of failures to a later step in the pipeline. The plugin scans directories specified by input globs for JUnit XML test reports, and will exit with status 1 if it finds any test failures.
How it works
Set the failure strategy of the step that runs the tests to ignore failures.
Use the parse-test-reports plugin in a subsequent Plugin step to scan the test report directories set in the plugin, and fail the build if any failures are found.
Usage Example
In the above example, Harness will scan for JUnit XML test reports in folder1 and folder2, and will fail (exit status 1) in case failures are detected in the JUnit XML test reports found in the folders scanned.
Test report dashboard
The Unit Test Metrics dashboard aggregates data from test reports in JUnit XML format. The dashboard reports the overall failure rate and the overall success rate. The dashboard breaks down failure data by pipeline, Git repo, and test. You can filter by project, pipeline, and date range.
You can find this and other dashboards under the Dashboards section of your Harness account.
Troubleshoot test reports
Go to the CI Knowledge Base for questions and issues related to test reports in Harness CI, including:
Last updated
Was this helpful?