Gitlab Version: v14.1.1 Gitlab pipeline is succeeding even though there is a failed test cases in unit test.
Gitlab.yaml code:
unit-test:
stage: Test
script:
- npm run test
needs:
- lint
artifacts:
when: always
paths:
- coverage
reports:
junit:
- junit.xml
cobertura:
- coverage/cobertura-coverage.xml
expire_in: 4 days
only:
- test-case-testing
- merge_requests
Test Results:
Update: test command used in package.json
"test": "node ./node_modules/nyc/bin/nyc.js --reporter=cobertura --reporter=html node_modules/cucumber/bin/cucumber-js src/use-cases --parallel 5 --format=json --fail-fast --require \"src/use-cases/**/!(index).js\" | cucumber-junit > junit.xml",
How can I abort the Gitlab pipeline when there are any failed test cases? I read this but couldn't figure out what exact changes should I do?
CodePudding user response:
Following change in script managed the failure.
stage: Test
script:
- npm run test
- test -f junit.xml && grep -L "<failure" junit.xml
and this resolved the issue.