Introduction
Unit test reports
Unit test reports display test results directly in merge requests and pipeline details, so you can identify failures without searching through job logs.
Unit test reports require the JUnit XML format and do not affect job status. To make a job fail when tests fail, your job’s script must exit with a non-zero status.
GitLab Runner uploads your test results in JUnit XML format as artifacts. When you go to a merge request, your test results are compared between the source branch (head) and target branch (base) to show what changed.
Configure unit test reports
Configure unit test reports to display test results in merge requests and pipelines.
To configure unit test reports:
- Configure your test job to output JUnit XML format test reports.
- In your
.gitlab-ci.ymlfile, addartifacts:reports:junitto your test job. - Specify the path to your XML test report files.
- Optional. To make report files browsable, include them with
artifacts:paths. - Optional. To upload reports even when jobs fail, use
artifacts:when:always.
Example configuration for Python:
test: stage: test image: ghcr.io/astral-sh/uv:debian script: - uv sync - uv run pytest --junitxml=report.xml artifacts: when: always reports: junit: report.xmlYou can view test results:
- In the Tests tab of pipeline details after your test job completes.
- In the Test summary panel of merge requests after your pipeline completes.

