Coverage 0.0% even though there are tests

  • versions used: sonarqube:latest and sonarsource/sonar-scanner-cli docker images
  • error observed: Coverage 0.0% even though there are tests

I have this in my sonar-project.properties config:

sonar.coverageReportPaths=./coverage/sonar.xml

My test generates coverage/sonar.xml file as:

<?xml version="1.0" encoding="utf-8"?>
<coverage version="1">
    <file path="test\auth\functions\jwt\jwt.token.refresh.spec.ts">
        <testCase name="jwt.token.times test expect _refresh to be a function" duration="0"/>
        <testCase name="jwt.token.times test expect jwtTokenRefresh to be a function" duration="1"/>
        <testCase name="jwt.token.times test expect jwtTokenRefresh to work" duration="12"/>
    </file>
    <file path="test\auth\functions\jwt\jwt.token.times.spec.ts">
        <testCase name="jwt.token.times test expect EXPIRES to be 1800" duration="0"/>
        <testCase name="jwt.token.times test expect _nowRounded to be a function" duration="0"/>
        <testCase name="jwt.token.times test expect _nowRounded to work" duration="0"/>
        <testCase name="jwt.token.times test expect jwtTokenTimes to be a function" duration="0"/>
        <testCase name="jwt.token.times test expect jwtTokenTimes to work for no value passed" duration="0"/>
        <testCase name="jwt.token.times test expect jwtTokenTimes to work for 3600000 passed" duration="0"/>
    </file>
</coverage>

Yet, when I run the scanner I get Coverage 0.0% and 0 for both files mentioned in sonar.xml above.

Hi,

What does your analysis log show?

Ā 
Ann

1 Like

Hi, sorry for the late reply.

I believe this ended up not being a sonarqube issue, but an issue with gitlab ci artifacts.

All is well now and sonarqube is reporting coverage properly :slight_smile:

2 Likes