Unit Test Report failures should cause the job/pipeline to fail
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
The Unit Test Report documentation says:
It is very common that a CI/CD pipeline contains a test job that verifies your code. If the tests fail, the pipeline fails and users get notified.
(emphasis mine)
But that's not what actually happens in GitLab CI — failures in the Unit Test Report don't seem to affect the success or failure of a job/pipeline. The documentation seems inconsistent with the actual behavior.
Steps to reproduce
- Create
.gitlab-ci.yml:andtest-behat: script: echo running behat artifacts: reports: junit: default.xmldefault.xml:<?xml version="1.0" encoding="UTF-8"?> <testsuites name="default"> <testsuite name="Tika" tests="1" skipped="0" failures="1" errors="0" time="1"> <testcase name="Tika can extract text from an image via OCR" classname="Tika" status="failed" time="1" file="features/Tika. feature"> <failure message="Then I should see "HTTP/1.1 200 OK": Expected output to match "HTTP/1.1 200 OK", but it didn't. Actual output: "HTTP/1.1 422 Unprocessable Entity Date: Thu, 31 Oct 2024 13:37:15 GMT Content-Length: 0 " (Exception)"></failure> </testcase> </testsuite> </testsuites> - Commit and push changes to a GitLab project
- The pipeline runs, and the job and pipeline unexpectedly succeed
Example Project
https://gitlab.com/smokris/test-ci-junit-fail
What is the current bug behavior?
Despite the Unit Test Report indicating a failed test — <testsuite failures="1"> and <testcase status="failed">and` — the job and pipeline succeed.
What is the expected correct behavior?
As mentioned in the documentation: "If the tests fail, the pipeline fails"
Relevant logs and/or screenshots
https://gitlab.com/smokris/test-ci-junit-fail/-/jobs/8244366038:
Output of checks
This bug happens on GitLab.com
