Overall Coverage increase in a Quality Gate

Hello,
I am using Sonar Version 6.7.5.
I want to force my team to increase the overall code coverage and I’d like to configure my Quality Gate for that. I have a Leak Period set to 30 days.
What I want to achieve is if overall code coverage doesn’t increase by 1% in a period of 30 days I want my project to fail.
In a Quality Gate metrics I see a condition called “Coverage” and I’d like to use that, because current Coverage is 1%. So here’s a scenario:
Currently there is 1% coverage. If in 30 days it won’t be 2%, the project should fail.

Setting:
Coverage (over leak period) is greater than 1 doesn’t seem to work :confused:

Do you guys have any idea what am I doing wrong? How should I configure my quality gate to fulfill my needs? Thanks in advance

Hi,

If this is really what you want to do (it’s not what we would advise) you’ll need to manually increment the QG condition value.

Far better, IMO to require high coverage on New Code. This way code that gets worked on frequently very quickly gets to a high level of coverage. Code that doesn’t get touched doesn’t get tests added but that’s okay since the point of tests is making sure you can change the code without problems and … you’re not changing the code.

 
Ann

1 Like

I assume the numbers 1 and 2 are just examples and not the real coverage :). If it is really that low, first of all make sure you are checking for the “real” source code and not the entire source code of your project which might include any auto-generated code or framework libraries or any third party code. You can set coverage exclusions by going to ‘Analysis Scope’ under Administration - Configuration.

Anyways, you may consider two options to achieve your objective:
Option 1 - Set Quality Gate (Coverage) to fail if it is less than 2% (not 1), which means it will start failing from today, and the moment it reaches 2%, it would Pass.
Option 2 - Set Quality Gate (Coverage) to fail if it is less than 1% and then on 30th day, manually update it to 2% and run the scan. If it is more than 2% the QG would pass, else it would fail.

1 Like

This is a really, really old PLSQL system, and I am not joking, coverage is 1% :smiley:
Thank you very much for the answers.
I’ll try to figure out “Coverage on New Code” because right now it shows “__” :slight_smile: