dotnet-coverlet

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Coverlet for .NET

适用于.NET的Coverlet

Trigger On

适用场景

  • the repo uses or wants
    coverlet
  • CI needs line or branch coverage for .NET tests
  • the team needs to choose between
    coverlet.collector
    ,
    coverlet.msbuild
    , or
    coverlet.console
  • 代码仓库正在使用或想要使用
    coverlet
  • CI需要为.NET测试生成行覆盖率或分支覆盖率数据
  • 团队需要在
    coverlet.collector
    coverlet.msbuild
    coverlet.console
    之间做选型

Value

价值

  • produce a concrete project delta: code, docs, config, tests, CI, or review artifact
  • reduce ambiguity through explicit planning, verification, and final validation skills
  • leave reusable project context so future tasks are faster and safer
  • 生成具体的项目变更:代码、文档、配置、测试、CI或评审产物
  • 通过明确的规划、验证和最终校验能力减少歧义
  • 留下可复用的项目上下文,让后续任务执行更快速安全

Do Not Use For

不适用场景

  • coverage report rendering by itself
  • repos that intentionally use a different coverage engine
  • 仅用于覆盖率报告渲染的场景
  • 明确使用其他覆盖率引擎的代码仓库

Inputs

输入依赖

  • the nearest
    AGENTS.md
  • active runner model: VSTest or Microsoft.Testing.Platform
  • target test projects
  • 最近的
    AGENTS.md
    文件
  • 活跃的运行器模型:VSTest 或 Microsoft.Testing.Platform
  • 目标测试项目

Quick Start

快速开始

  1. Read the nearest
    AGENTS.md
    and confirm scope and constraints.
  2. Run this skill's
    Workflow
    through the
    Ralph Loop
    until outcomes are acceptable.
  3. Return the
    Required Result Format
    with concrete artifacts and verification evidence.
  1. 阅读最近的
    AGENTS.md
    文件,确认范围和约束条件。
  2. 通过
    Ralph Loop
    运行本技能的工作流,直到输出结果符合预期。
  3. 按照「要求结果格式」返回具体产物和验证证据。

Workflow

工作流

  1. Choose the driver deliberately:
    • coverlet.collector
      for VSTest
      dotnet test --collect
    • coverlet.msbuild
      for MSBuild property-driven runs
    • coverlet.console
      for standalone scenarios
  2. Add coverage packages only to test projects.
  3. Do not mix
    coverlet.collector
    and
    coverlet.msbuild
    in the same test project.
  4. Pair raw coverage collection with
    ReportGenerator
    only when humans need rendered reports.
  1. 谨慎选择驱动类型:
    • 若使用VSTest的
      dotnet test --collect
      命令,选择
      coverlet.collector
    • 若使用MSBuild属性驱动的运行方式,选择
      coverlet.msbuild
    • 独立部署场景选择
      coverlet.console
  2. 仅在测试项目中添加覆盖率相关包。
  3. 不要在同一个测试项目中混用
    coverlet.collector
    coverlet.msbuild
  4. 仅当需要人工查看渲染后的报告时,才将原始覆盖率收集结果和
    ReportGenerator
    搭配使用。

Bootstrap When Missing

缺失配置时的初始化流程

If coverage is not configured yet:
  1. Detect current state:
    • rg -n "coverlet\\.(collector|msbuild)|CollectCoverage|XPlat Code Coverage" -g '*.csproj' -g '*.props' -g '*.targets' .
    • dotnet tool list --local
    • dotnet tool list --global
    • command -v coverlet
  2. Install exactly one driver path:
    • VSTest collector:
      dotnet add TEST_PROJECT.csproj package coverlet.collector
    • MSBuild driver:
      dotnet add TEST_PROJECT.csproj package coverlet.msbuild
    • Console tool:
      dotnet new tool-manifest
      (if missing) and
      dotnet tool install coverlet.console
  3. Record one concrete local and CI command in
    AGENTS.md
    :
    • collector:
      dotnet test TEST_PROJECT.csproj --collect:"XPlat Code Coverage"
    • msbuild:
      dotnet test TEST_PROJECT.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
    • console:
      dotnet tool run coverlet TEST_ASSEMBLY.dll --target "dotnet" --targetargs "test TEST_PROJECT.csproj --no-build"
  4. Run the chosen command once and return
    status: configured
    or
    status: improved
    .
  5. If another coverage engine already owns coverage for this repo, return
    status: not_applicable
    .
如果尚未配置覆盖率统计:
  1. 检测当前状态:
    • rg -n "coverlet\\.(collector|msbuild)|CollectCoverage|XPlat Code Coverage" -g '*.csproj' -g '*.props' -g '*.targets' .
    • dotnet tool list --local
    • dotnet tool list --global
    • command -v coverlet
  2. 仅安装一种驱动:
    • VSTest collector:
      dotnet add TEST_PROJECT.csproj package coverlet.collector
    • MSBuild驱动:
      dotnet add TEST_PROJECT.csproj package coverlet.msbuild
    • 控制台工具:如果缺少工具清单则先执行
      dotnet new tool-manifest
      ,再执行
      dotnet tool install coverlet.console
  3. AGENTS.md
    中记录一条可用于本地和CI环境的具体命令:
    • collector:
      dotnet test TEST_PROJECT.csproj --collect:"XPlat Code Coverage"
    • msbuild:
      dotnet test TEST_PROJECT.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
    • console:
      dotnet tool run coverlet TEST_ASSEMBLY.dll --target "dotnet" --targetargs "test TEST_PROJECT.csproj --no-build"
  4. 运行一次选择的命令,返回
    status: configured
    status: improved
  5. 如果本仓库已经使用其他覆盖率引擎,返回
    status: not_applicable

Deliver

交付产物

  • explicit coverage driver selection
  • reproducible coverage commands for local and CI runs
  • 明确的覆盖率驱动选型结果
  • 可复现的本地和CI环境覆盖率运行命令

Validate

校验标准

  • coverage driver matches the runner model
  • coverage files are stable and consumable by downstream reporting
  • 覆盖率驱动与运行器模型匹配
  • 覆盖率文件稳定,可被下游报告工具消费

Ralph Loop

Ralph Loop

Use the Ralph Loop for every task, including docs, architecture, testing, and tooling work.
  1. Plan first (mandatory):
    • analyze current state
    • define target outcome, constraints, and risks
    • write a detailed execution plan
    • list final validation skills to run at the end, with order and reason
  2. Execute one planned step and produce a concrete delta.
  3. Review the result and capture findings with actionable next fixes.
  4. Apply fixes in small batches and rerun the relevant checks or review steps.
  5. Update the plan after each iteration.
  6. Repeat until outcomes are acceptable or only explicit exceptions remain.
  7. If a dependency is missing, bootstrap it or return
    status: not_applicable
    with explicit reason and fallback path.
所有任务都需使用Ralph Loop,包括文档、架构、测试和工具类工作。
  1. 首先做规划(强制要求):
    • 分析当前状态
    • 定义目标产出、约束和风险
    • 编写详细的执行计划
    • 列出最终要运行的校验能力,说明顺序和原因
  2. 执行一个规划好的步骤,生成具体的变更。
  3. 评审结果,记录发现的问题和可执行的后续修复方案。
  4. 小批量应用修复,重新运行相关检查或评审步骤。
  5. 每次迭代后更新规划。
  6. 重复以上步骤直到产出符合预期,或仅剩下明确的例外项。
  7. 如果缺少依赖,先初始化依赖,或返回
    status: not_applicable
    ,同时说明明确原因和备选方案。

Required Result Format

要求结果格式

  • status
    :
    complete
    |
    clean
    |
    improved
    |
    configured
    |
    not_applicable
    |
    blocked
  • plan
    : concise plan and current iteration step
  • actions_taken
    : concrete changes made
  • validation_skills
    : final skills run, or skipped with reasons
  • verification
    : commands, checks, or review evidence summary
  • remaining
    : top unresolved items or
    none
For setup-only requests with no execution, return
status: configured
and exact next commands.
  • status
    :可选值
    complete
    |
    clean
    |
    improved
    |
    configured
    |
    not_applicable
    |
    blocked
  • plan
    :简洁的计划和当前迭代步骤
  • actions_taken
    :已执行的具体变更
  • validation_skills
    :最终运行的校验能力,若跳过需说明原因
  • verification
    :命令、检查或评审证据的汇总
  • remaining
    :最主要的未解决事项,若无则填
    none
对于仅要求配置无需执行的请求,返回
status: configured
和准确的后续执行命令。

Load References

参考文档

  • references/commands.md
  • references/patterns.md
  • references/coverlet.md
  • references/commands.md
  • references/patterns.md
  • references/coverlet.md

Example Requests

请求示例

  • "Add Coverlet to this .NET solution."
  • "Choose the right Coverlet driver for CI."
  • "给这个.NET解决方案添加Coverlet支持。"
  • "为CI环境选择合适的Coverlet驱动。"