Failure Coverage new code 0%

Java.
Created a new branch.
Added small amount of new code.
Provided excessive amount of tests, like twice for every line of new code.
Sonar is failing with “Coverage new code 0%, required 80%”.
Tried to re-build multiple times.
Created a different NEW branch. Manually moved new code and new tests from previous into the new branch. So for Sonar this a a one shot brand new story.
Tried to rebuild this new branch. Exactly the same failure. 0% coverage.
See picture.
Any suggestion?
Thanks a lot.

Hi,

Welcome to the community!

Maybe this is a stupid question, but you are generating a coverage report and feeding it into analysis, right?

 
HTH,
Ann

I know very little about this process. The first time I am facing Sonar.
Sonar version 8.8.0

Output from Azure build
2022-01-21T21:31:45.9608595Z ========================== Starting Command Output ===========================
2022-01-21T21:31:45.9629404Z [command]/usr/bin/bash --noprofile --norc XYZ/_temp/439338d6-09bb-49d3-9685-73a25a322236.sh
2022-01-21T21:31:45.9683629Z (node:66052) Warning: Use Cipheriv for counter mode of aes-256-ctr
2022-01-21T21:31:45.9692123Z QG Script → Using SonarQube instance https://XYZ.com/sonar/2
2022-01-21T21:31:45.9753169Z QG Script → Using task id of AX5-i_HPbexesbE9y0sF
2022-01-21T21:31:46.2194003Z QG Script → Status of SonarQube task is SUCCESS
2022-01-21T21:31:51.4635017Z QG Script → Using analysis id of AX5-jCVcC3ApsBGx_43V
2022-01-21T21:31:51.6972772Z QG Script → Quality Gate status is ERROR
2022-01-21T21:31:51.7003744Z ##[error]SonarQube Quality Gate has FAILED! For more details check on SonarQube. The pipeline will continue to run with this warning.
2022-01-21T21:31:51.7054546Z ##[section]Finishing: Checking Quality Gate

Hi,

SonarQube doesn’t run your coverage for you; it only reflects the coverage reports you feed into analysis. So first, you’ll need to make sure you’re running your tests and generating a coverage report. The details of that will vary by language and actually generating the report is outside the scope of this community. But the docs will help with the import.

 
HTH,
Ann

1 Like