Code coverage is showing 0









This is sonar properties file we are using , in the Log files I am seeing

**1:49:58** INFO: Analysing [/var/jenkins_home/workspace/build-webapp-api/repo/src/platform/custom/coverage/] 
**11:49:58** WARN: Could not resolve 4 file paths in [/var/jenkins_home/workspace/build-webapp-api/repo/src/platform/custom/coverage/] 
**11:49:58** WARN: First unresolved path: /var/jenkins_home/workspace/build-webapp-api/repo/src/platform/custom/test/cart.spec.js (Run in DEBUG mode to get full list of unresolved paths)

Can someone help me with this ?


Welcome to the community!

I think we should probably sort out your analysis parameters before we get to the coverage reports.

This property expects paths or patterns that describe paths to files. What you’ve specified doesn’t include the final, file part. The ** means “0-n directories”. For the first two, I’m guessing you meant:

This assumes that coverage and node_modules exist in your project root…? For the third value, what you’ve specified indicates that report.xml also exists in project root…?

This property doesn’t actually exist. I guess you’re trying to make sure that your test files aren’t analyzed as source code? In that case, I would recommend an addition to your list of sonar.exclusions: **/test/**/*.js

Doing that may sort out this error, since the ‘missing’ file seems to actually be a test file…?

So, can you make these changes and see if the results are any better?


Sure , Let me try the mentioned steps.

Thanks that’s fixed the issue, code coverage started showing now , however we are still seeing the warn

INFO: Analysing [/var/jenkins_home/workspace/build-webapp-api/repo/src/platform/custom/coverage/] 18:24:23 WARN: Could not resolve 4 file paths in [/var/jenkins_home/workspace/build-webapp-api/repo/src/platform/custom/coverage/] 18:24:23 WARN: First unresolved path: /var/jenkins_home/workspace/build-webapp-api/repo/src/platform/custom/test/cart.spec.js (Run in DEBUG mode to get full list of unresolved paths)


You can turn on debug logging to see what those 4 paths are. But from the first path, it looks like your coverage report includes test coverage of tests…


I would also love to know which parameter Define the amount to Lines to cover , is that the Unit Test cases written. I am new to sonarqube and would like to know more about the way the coverage works.

As I told I can see the coverage coming but only 22% is shown , I need to know why its knot covering fully. Can you suggest some good documentation to Read.


Lines to cover isn’t defined by a parameter. For the files included in your coverage report, we use what the report provides. For the files omitted from your coverage report, we calculate executable lines.

This blog may also help.