Replace this template with your information
Describe your question in as much detail as possible:
I’m trying to get the coverage percentage to show in jobs tab of my project but it’s always showing 0.00% even though I see the result is different than that number.
-
What are you seeing, and how does that differ from what you expect to see?
I get 0.00% but I should get 16.33% for instance. -
Consider including screenshots, error messages, and/or other helpful visuals
I get this result in my test job.
./vendor/phpunit/phpunit/phpunit -v --coverage-text --coverage-cobertura=coverage.cobertura.xml --colors=never --stderr --log-junit report.xml
PHPUnit 9.5.19 #StandWithUkraine
Runtime: PHP 7.4.14 with Xdebug 3.0.2
Configuration: /builds/steve-moretz-php/laravel/tools/phpunit.xml
SteveMoretz\Tools\Tests\Unit\Tools\PaginationTest
[1/4] ✓ start from 1 [0.258s]
[2/4] ✓ start from 0 [0.089s]
[3/4] ✓ custom data key [0.086s]
[4/4] ✓ custom total key [0.084s]
Time: 00:00.672, Memory: 32.00 MB
OK (4 tests, 15 assertions)
Generating code coverage report in Cobertura XML format ... done [00:00.090]
Code Coverage Report:
2022-03-29 11:46:58
Summary:
Classes: 0.00% (0/8)
Methods: 25.71% (9/35)
Lines: 16.33% (48/294)
SteveMoretz\Tools\Laravel\app\Providers\ToolsServiceProvider
Methods: 50.00% ( 1/ 2) Lines: 31.63% ( 31/ 98)
SteveMoretz\Tools\Laravel\app\Tools\DB\PaginationDefinition
Methods: 57.14% ( 8/14) Lines: 53.12% ( 17/ 32)
SteveMoretz\Tools\Laravel\app\Tools\DB\WithOptimized
Methods: 0.00% ( 0/ 1) Lines: 0.00% ( 0/ 1)
SteveMoretz\Tools\Laravel\tests\TestsInteractables
Methods: 0.00% ( 0/ 8) Lines: 0.00% ( 0/ 76)
SteveMoretz\Tools\Utils\DB\DBUtils
Methods: 0.00% ( 0/ 2) Lines: 0.00% ( 0/ 22)
SteveMoretz\Tools\Utils\MultiDrivers\Facades\MultiDriversManager
Methods: 0.00% ( 0/ 1) Lines: 0.00% ( 0/ 1)
SteveMoretz\Tools\Utils\MultiDrivers\Managers\UtilsMultiDriversManager
Methods: 0.00% ( 0/ 5) Lines: 0.00% ( 0/ 33)
SteveMoretz\Tools\Utils\Traits\SerializeObjectVarsViaArray
Methods: 0.00% ( 0/ 2) Lines: 0.00% ( 0/ 28)
Uploading artifacts for successful job
00:02
Uploading artifacts...
report.xml: found 1 matching files and directories
Uploading artifacts as "junit" to coordinator... 201 Created id=2264065407 responseStatus=201 Created token=VGqynB_U
Uploading artifacts...
coverage.cobertura.xml: found 1 matching files and directories
Uploading artifacts as "cobertura" to coordinator... 201 Created id=2264065407 responseStatus=201 Created token=VGqynB_U
Cleaning up project directory and file based variables
00:01
Job succeeded
And I get this at the tab:
-
What version are you on? Are you using self-managed or GitLab.com?
NO- GitLab (Hint:
/help
): - Runner (Hint:
/admin/runners
):
- GitLab (Hint:
-
Add the CI configuration from
.gitlab-ci.yml
and other configuration if relevant (e.g. docker-compose.yml)
test:
stage: test
coverage: '/^\s*Lines:\s*\d+.\d+\%/'
variables:
XDEBUG_MODE: coverage
dependencies:
- install
script:
- ./vendor/phpunit/phpunit/phpunit -v --coverage-text --coverage-cobertura=coverage.cobertura.xml --colors=never --stderr --log-junit report.xml
artifacts:
when: always
reports:
cobertura: coverage.cobertura.xml
junit: report.xml
- What troubleshooting steps have you already taken? Can you link to any docs or other resources so we know where you have been?
I have used the regex from : Customize pipeline configuration | GitLab