Dear all, I have a simple question about quality gate and test coverage.
If I do not have any test in a project and the quality gate condition on coverage is <50% (for instance), shouldn’t the quality gate fail?
What I am experiencing is that projects with no tests, do not fail because no tests are found, and I am only achieving the quality gate to fail when I add to the quality gate the condition lines to cover >0.
If you haven’t written any tests for your codebase, you won’t generate a coverage report. In this situation, SonarQube interprets the absence of a coverage report as a lack of configuration or integration for test coverage reporting, rather than assuming there are no tests or coverage at all.
Without a coverage report, SonarQube can’t assess your coverage status accurately, so the absence is treated as a configuration issue—not as evidence that there is zero test coverage.
For many users, coverage reporting is a second step after getting analysis up and running for the first time.
Since the default Sonar Way Quality Gate includes a condition for test coverage, but not all projects necessarily have tests, having no tests will not automatically cause a quality gate failure. Additionally, some languages (for example, COBOL) technically support coverage measurement, but coverage tools for them are uncommon and not typically part of most projects.
Dear Colin,
I can understand that SonarQube interprets the absence of a coverage report as a lack of configuration. However, our reality is that projects that do not implement tests are passing the quality gate, not complying with the company agreements and being undetected. In order to detect those violations we had to add to the quality gate the condition “lines to cover>0”.
I just wanted to provide a little feedback about our situation, but I understand that this is how SonarQube is configured.