Quality Gate passed even with zero coverage


(Michał Rymarczyk) #1


We are using metric “Condition Coverage on New Code” in our quality gates. But it doesn’t
work properly for projects which don’t have any tests. For some projects which didn’t have any
tests, we’ve added some code not covered by test and Quality Gate should fail because code was
added after leak period - our QG configuration is in attach

ment. But unfortunately Quality Gate passed… Ou I’ve found some post related with
that problem https://stackoverflow.com/questions/39529432/sonarqube-projects-pass-quality-
gate-when-there-is-no-data. Maybe You can help me with solution.

Best Regards,
Mike Rymarczyk

(G Ann Campbell) #2

Hi Mike,

What does your project homepage show for coverage in the New Code (Leak) period? A dash or a 0? Also, how many new, uncovered lines did you add?


(Michał Rymarczyk) #3

Hi Ann,

Here is an example of project with no tests on new classes and despite having Condition "Condition coverage on new code " project passed QG. We use jacocco plugin to report test coverage


(G Ann Campbell) #4

Hi Mike,

How about a screenshot of your project homepage?


(Andreas Huber) #5

I have the exact same problem. On one project it worked with a minimum of 95% coverage.
On two others the quality gate did not fail.

I created a little public test project with some sample code. It includes unit tests, but the newly added code has a coverage of 0%.

The coverage on new code is nowhere near the 80% the “Sonar Way” quality gate requires.

Quality Gate + Short Lived Branches
(G Ann Campbell) #6


That’s a screenshot from a PR or short-lived branch (SLB). Your hand-crafted Quality Gate isn’t applied to it. PRs and SLBs go red/green based purely on the presence/absence of Open issues.

Is this a sub-optimal situation? Yes.

Is it on our radar? Definitely. See

MMF-1369 - Real Quality Gates for PRs and short-lived branches

This is currently tentatively scheduled for 7.6, E.T.A. 2019Q1


(Andreas Huber) #7

Hi Ann,
thank you for the clarification. I hope it will make the Q1 release. But for now, I can live with that.