Sonarqube 9.9 LTS coverage issues

Hi
Sonarqube version : 9.9.1.69595
System information :
Operating system:windows server 2022
Java version:jdk11
Database provider/version:MSSQL 2017

In the Branch environment, when using the coverage detection checker, it shows 0.0%, but in Code, it shows that Coverage has been checked.
Coverage uses dotCover.

The following is the coverage displayed by the Trunk Code and the Branch Code.
Show that Branch has Coverage Fully covered by tests.

Trunk Code has no coverage

Branch Code has coverage

But Branch Coverage shows 0.0%
ERROR3

What should I do?

Hi,

Welcome to the community!

Do you run exactly the same pipeline for both main and branches?

 
Ann

Hi Ann,
Make sure to use the master branch to run the exact same pipeline.
image

I found that if the new coverage is tested on the old Code, the branch coverage cannot be calculated.

You need to change the location of the tested Code before NewCode will be recorded and the branch coverage will be calculated.

Is there a problem with this setting?

Hi,

Sorry, but I’m not following.

Are you saying you have to move the code before it shows up as New Code and its coverage shows up as Coverage on New Code? Yes, moving code will cause it to be marked new, even if the code itself is unchanged.

Backing up to your initial post, your final screenshot shows coverage on New Code, but I don’t think I’m seeing new code markings in either of the other two screenshots.

Can you restate the basic problem here?

 
Ann

Hi Ann:

Original question:
Yes, the picture shows the original Code, without UnitTest. When judging Coverage, the Trunk Code shows no Coverage. (first picture)
And I wrote UnitTest to cover the Code and scan the Branch (second picture)
It is confirmed that there is UnitTest in Code, but during Coverage, Coverage is not calculated. (Third picture)

After asking the questions, the test found that

Later, it was discovered that the block covered by Coverage needed to be moved
For example: There are three blocks
The UnitTest I wrote is testing the second block of Code
The Code of the second block needs to be transferred to the third block.
Only in this way will Coverage calculate the data.

UnitTest’s code needs to be converted to the new code.
In this way, the value of Coverage can be obtained in Branch.

Hi,

Okay, so the second and third pictures show the same branch. As the code-level picture affirms, there is some coverage, but what’s reported on the branch homepage is 0.0 on New Lines.

That’s because (as we see in the 2nd screenshot) the covered lines aren’t new (added or edited in the New Code period).

So yes, to get the newly-covered lines to show up under Coverage on New Code, you have to move them / edit them to make them “new”.

That’s as designed.

All that said, if your goal is to move the “Coverage on New Code” needle, what you should be looking at and writing tests for are the “424 New Lines to cover” shown in the 3rd screenshot of your initial post. Click through on that number to get to the files with new lines. From there, click on a file to see which lines are new. And write tests for those lines.

 
HTH,
Ann

Hi Ann:

I understand, thanks for your reply.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.