coverage
The 95% line coverage gate - what counts, what is excluded and why, and how to measure it locally the same way the pipeline does. Use when coverage fails, when adding code that is hard to test, or before opening a pull request.
Install
npx skills add https://github.com/LeanMeanCleanApps/CleanMinimalApi/tree/main/.agents/skills/coverage
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install leanmeancleanapps-cleanminimalapi@llmmart
git clone https://github.com/LeanMeanCleanApps/CleanMinimalApi.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole leanmeancleanapps/cleanminimalapi collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Coverage
The rule
Total line coverage across every test project, merged into one report, must be at least 95%. The pipeline fails below that, and nobody lowers the number. Coverage comes from Coverlet (coverlet.msbuild).
Excluded on purpose, and only these:
| Excluded | How | Why |
|---|---|---|
Program.cs |
ExcludeByFile |
Startup glue, exercised by integration tests but not meaningfully measurable |
Migrations/*.cs |
ExcludeByFile |
Generated by EF Core |
obj/** and [GeneratedCode] |
ExcludeByFile, ExcludeByAttribute |
Source generators (Mediator, Mapperly, JSON) |
| Wiring and plain models | [ExcludeFromCodeCoverage] on the class |
Dependency registration (DependencyInjection), startup extensions, database models with no logic |
Steps
Measure locally with the same settings as the pipeline (run from the repository root):
dotnet test -m:1 \ -p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" \ -p:CoverletOutputFormat=opencover%2cjson \ -p:ExcludeByFile="**/Program.cs%2c**/Migrations/*.cs%2c**/obj/**/*.cs" \ -p:ExcludeByAttribute="GeneratedCodeAttribute"The last table printed shows the merged total.
Uncovered lines? Write a test for the behaviour (
unit-tests,integration-tests). Branches that can't happen usually mean the code can be simpler.Use
[ExcludeFromCodeCoverage]only for wiring and plain data classes, never for code with decisions in it.
Don't
- Lower the threshold, or add a file pattern to the exclusions to get green.
- Add
[ExcludeFromCodeCoverage]to a handler, validator, repository, endpoint or mapper. - Write tests that execute lines without asserting anything.
Check
The command in step 1, or push and read the Test row of the pipeline's Summary comment.
Files (cleanminimalapi)
-
SKILL.md 2.1 KB
--- name: coverage description: The 95% line coverage gate - what counts, what is excluded and why, and how to measure it locally the same way the pipeline does. Use when coverage fails, when adding code that is hard to test, or before opening a pull request. metadata: scope: shared --- # Coverage ## The rule Total line coverage across every test project, merged into one report, must be at least 95%. The pipeline fails below that, and nobody lowers the number. Coverage comes from Coverlet (`coverlet.msbuild`). Excluded on purpose, and only these: | Excluded | How | Why | | --- | --- | --- | | `Program.cs` | `ExcludeByFile` | Startup glue, exercised by integration tests but not meaningfully measurable | | `Migrations/*.cs` | `ExcludeByFile` | Generated by EF Core | | `obj/**` and `[GeneratedCode]` | `ExcludeByFile`, `ExcludeByAttribute` | Source generators (Mediator, Mapperly, JSON) | | Wiring and plain models | `[ExcludeFromCodeCoverage]` on the class | Dependency registration (`DependencyInjection`), startup extensions, database models with no logic | ## Steps 1. Measure locally with the same settings as the pipeline (run from the repository root): ``` bash dotnet test -m:1 \ -p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" \ -p:CoverletOutputFormat=opencover%2cjson \ -p:ExcludeByFile="**/Program.cs%2c**/Migrations/*.cs%2c**/obj/**/*.cs" \ -p:ExcludeByAttribute="GeneratedCodeAttribute" ``` The last table printed shows the merged total. 2. Uncovered lines? Write a test for the behaviour (`unit-tests`, `integration-tests`). Branches that can't happen usually mean the code can be simpler. 3. Use `[ExcludeFromCodeCoverage]` only for wiring and plain data classes, never for code with decisions in it. ## Don't - Lower the threshold, or add a file pattern to the exclusions to get green. - Add `[ExcludeFromCodeCoverage]` to a handler, validator, repository, endpoint or mapper. - Write tests that execute lines without asserting anything. ## Check The command in step 1, or push and read the Test row of the pipeline's Summary comment.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.