For this project I was using Laravel 12 and PhpUnit 11 with PCOV for coverage. What I wanted to do was to have the test result’s coverage percentage to show up in gitlab but it’s not showing up. My gitlab-ci.yaml file correctly uploads the artifacts for the generated cobertura formatted xml file and the “coverage” line with the regex for parsing the coverage percent value.
I later realized that the “coverage” keyword in gitlab-ci was for parsing what’s being printed out in the terminal (as you would see in the pipeline job’s log). Unfortunately I’m not seeing my test coverage results in the log.
Coverage result was being generated into a file but for some reason running tests with parametter –coverage-text or –coverage doesn’t print the coverage results in the terminal. I also tested these different parameters/commands locally and I was not able to print the results to my terminal.
As a last resort here’s what I did:
- use –coverage-text=my_coverage.txt -> to print the results to a file instead since that’s working
- print out the file’s contents to the terminal e.g. cat my_coverage.txt
- let gitlab perform the parse
After these updates test coverage result now shows up and being picked up by gitlab.
Cheers!
