Coverage on new code in PR: PR branch vs 'Estimated after merge'

I am using SonarCloud for PR build with codecoverage threshold 80%.
Codecoverage in PR branch is below 80%, while codecoverage “Estimated after merge” is above 80%
As main idea of PR to ensure that code in master branch is valid, i expect PR build to use “Estimated after merge” codecoverage value for quality gate, but actually it fails with PR branch coverage value.
Is it possible to specify settings to use “Estimated after merge” codecoverage for PR build, instead of current branch?
Thank you


No, it’s not possible and we probably won’t add this feature. With your suggestion, I could merge a PR with 0% coverage given a fairly small PR and large project.
You should not introduce new code that doesn’t match the quality level you choose for your project, so your pull request should have (at least) the same coverage percentage of what you want on master.


1 Like

Thank you for explicit answer

@benoit everyone has different use cases. We were currently working on getting quotes to renew our licenses for millions of lines of code between our contracts. We only want to block PR’s if coverage in the in main branch drops below a % that is defined in the contract. I could care less if it is an emergency PR and only has 10% coverage, it should pass, as long as the main branch doesn’t drop below the requirement.

Seems like an quick and easy check to put in since the status check already reports the coverage after merge to GitHub, just no way to define a threshold for it.

The ‘Estimated after merge’ is the estimated coverage on the overall codebase after you merge your PR.

Ref: How does Sonarqube calculates "Estimated after merge" for every PR?