Coverage report not showing anything in pipeline run

In the pipeline> jobs page, I am expecting to see some numerical value in the column titled “coverage report” which should indicate the type of coverage testing that was done. I am using below code in my .gitlab-ci.yaml file and the code creates the nosetests data for me as designed and shows me the nosetests that passed and failed, however the coverage report is not showing me anything in the pipeline> jobs page.

My runner is self hosted on my machine and my data is all hosted on gitlab.com

Please advise on any suggestions you have that could assist in getting the coverage report working.

script: #
- docker run --rm --network host -v (pwd):(pwd) -w $(pwd) paris nosetests --with-xcoverage --cover-package=london --cover-erase --no-byte-compile --with-xunit --verbosity=3
artifacts: # the always in when is saying that it should generate report even if it fails
when: always
paths:
- nosetests.xml
- coverage.xml
reports:
junit: nosetests.xml
cobertura: coverage.xml

@devopsfella - Thanks for posting! To parse a coverage value from the job logs you’ll need to setup a regular expression to parse the type of coverage you want to report. This value is then shown on the Jobs page, used on the MR page and to populate the test coverage history if it is setup for the default branch.

I hope this helps!

-James H, GitLab Product Manager, Verify:Testing

2 Likes

Thank you, I used pytest-cov (Python) - ^TOTAL.+?(\d+%)$ for parsing in pipeline setting and i see the coverage percentage value now.

Do you know if there is a way to see a detailed breakdown view of the packages from the coverage report?
In jenkins, there is an option where you click on coverage percentage value number and it takes you to a detailed page of the breakdown of the coverage. Does gitlab have anything similar?
The only reason i mentioned Jenkins as a reference is because we are migrating from Jenkins into Gitlab CI.

@devopsfella - Glad to see that worked for you!

Seeing coverage report contents directly in the UI is not available today but it is something we are looking at for the future. You can follow this epic for the work to see when issues are scheduled and comment on them.

In the mean time it is fairly simple to publish the .html version of a coverage report to GitLab pages and there is a blog post about it one of our engineers wrote a few years back.

I hope this helps you solve the problem and look forward to feedback on those issues if you have some.

-James H, GitLab Product Manager, Verify:Testing

1 Like

Why does the documentation then state that gitlab supports cobertura style xml, which is provided in pytest-cov “out of the box”?

1 Like

@awa5114

I’m not clear on the question. If you’ve followed the documentation example for python you should be seeing coverage annotation in the MR Diff. If you are looking to get the coverage value from the report that functionality is not yet built in GitLab. Coverage can be parsed from the job logs.

I hope this helps!

-James H, GitLab Product Manager, Verify:Pipeline Execution

I am trying to figure out why this is not working Code coverage | GitLab

this is my yaml

# .gitlab-ci.yml

image: node:12

# Define the stages of the pipeline
stages:
  - test

cache:
  paths:
    - node_modules/

# Define the job that will run tests
test:
  stage: test
  script:
    - npm install
    - npm run test -- --coverage --verbose
  artifacts:
    when: always
    paths:
      - junit.xml
      - coverage/cobertura-coverage.xml
    reports:
      coverage_report:
        coverage_format: cobertura
        path: coverage/cobertura-coverage.xml
      junit: junit.xml
  # Add coverage to code coverage statistics
  coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'

  # Define when this job should be executed
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "master"'


@shorif2000

The test coverage history graphs are only for coverage on the default branch so you may need to run the job on that branch before you see anything on the graph.

Hope that helps!

-James H, GitLab Product Manager, Analyze:Product Analytics