Gitlab CI, issues with dotcover and cobertura report

Hi all, i am moving from teamcity to gitlab. I was able to create a project and to run a pipeline of it every time that i do a commit. Now i want to add the feature regarding how many lines i tested when i send a MR but all the things that i tried fail.

i was able to generated a dotcover report and via reportgenerator generate a cobertura.xml report. But i dont know what i am doing wrong. Here is my CI file

default:
image: microsoft/dotnet:latest
stages:
- build
- test 
- cover
variables:
TEST: "HELLO WORLD"
TEST_PROJECT: "YES"
build:
tags:
    - windows
stage: build
script:
- echo $CI_JOB_STAGE
- dotnet build

test:
stage: test
tags:
    - windows
rules:
- if: '$TEST_PROJECT == "YES"'
script:    
    - echo "Excecuting tests"
    - dotnet test

cover:
stage: cover
tags:
    - windows
script:    
    - cd GitlabPOC.Test
    - dotnet restore
    - dotnet dotcover test --dcXML="DotCoverConfig.xml"
    - tools\reportgenerator.exe "-reports:dotcover.Output.xml" "-targetdir:coverage" -reporttypes:Cobertura 
artifacts:
    when: always
    reports:
        cobertura: GitlabPOC.Test\coverage\coverage.xml

someone has the same issue?

Other question that i have, is if there is a way to add to the MR more information regarding code coverage, something like this

Thanks in advance

Sebastian

@sherrera-hx thanks for the post!

It looks like your setup is correct but do note that the element is not supported currently so the Test Coverage Visualization feature assumes that filename and class element contain the full path.

If you are parsing a test coverage value from the job logs average test coverage, change related to the MR and a tooltip of each jobs’s coverage will be displayed on the MR page. There is an open epic with issues we are researching to determine next steps in showing more data like this on the MR and for the project and would be happy to hear your input there.

Hopefully this helps you get some more coverage data into your MRs!

-James Heimbuck, GitLab Product Manager, Verify:Testing

thanks @jheimbuck_gl for the answer. I was working on the code coverage during the last few days. The path issue that you wention i was able to fix, but something is already missing but i am not able to realize what it is. I Changed my CI file like this.

.cover:
stage: cover
coverage: '/CoveragePercent="\d+" ReportType/'
script:
    - cd GitlabPOC.Test
    - dotnet restore
    - dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.8.1  
    - export PATH="$PATH:/root/.dotnet/tools"
    - dotnet dotcover test --dcXML="DotCoverConfig.xml"
    - reportgenerator "-reports:dotCover.Output.xml" "-targetdir:coverage" -reporttypes:Cobertura 
    - sed -i "s|filename=\"$CI_PROJECT_DIR|filename=\"|g" coverage/Cobertura.xml
    - cat dotCover.Output.xml

artifacts:
    when: always        
    expire_in: 1 week
    paths: 
        - ./**/*Cobertura.xml
    reports:
        cobertura: ./**/*Cobertura.xml

I downloaded the artifact and nothing seemts to be bad. I dont know if i can upload it here to let you see it

@sherrera-hx - I want to clarify, which feature is still not working, coverage badge/value in the MR or the test coverage visualization?

-James H, GitLab Product Manager, Verify:Testing