Quality Gate Guide

Enforcing Coverage Thresholds

Don't just measure coverage—enforce it. Learn how to configure Coverlet to fail your build when coverage drops below your team's quality standards.

The MSBuild Threshold Pattern

The most common way to enforce thresholds is using the coverlet.msbuild package. You define your "Quality Gate" directly in your project file:

<!-- YourTestProject.csproj -->
<PropertyGroup>
  <Threshold>90</Threshold>
  <ThresholdType>line</ThresholdType>
</PropertyGroup>

The CLI Threshold Pattern

If you prefer a one-off check without modifying your project files, use the MSBuild properties via CLI:

dotnet test /p:CollectCoverage=true /p:Threshold=80
Important: If you are using the Collector driver, threshold enforcement is currently handled by external tools like ReportGenerator or specialized CI Actions.