boosting-coverage

用于在现有项目中提升单元测试覆盖率,为未测试代码添加测试,或在不能修改源代码且需覆盖所有逻辑分支的情况下快速提高覆盖率百分比并避免冗余测试。

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "boosting-coverage":https://skillpi.com/zh/skills/deepskill-b72430ab8b2375f4bb194ccd50b70d778456fd08c85316d63cf50d83b7f5cce3。安装前核对上游来源和版本:https://skillhub.cn/skills/user_e3e8b067/boosting-coverage。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

skillhub.cn

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

用于在现有项目中提升单元测试覆盖率,为未测试代码添加测试,或在不能修改源代码且需覆盖所有逻辑分支的情况下快速提高覆盖率百分比并避免冗余测试。

0 下载

介绍来源: third_party · user_e3e8b067 · 1.0.0 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: Boosting-Coverage
description: Use when asked to improve unit test coverage on an existing project, add tests to untested code, or rapidly increase coverage percentage — especially when source code must not be modified, all logic branches must be covered, and redundant tests must be avoided

Boosting Coverage

Overview

Read source → map every branch → write minimum tests hitting each branch → verify with coverage tool. Never modify source code. One test covers many branches on the same execution path.

Core Process

1. Survey & Map Branches (NO writing yet)

Scan project, sort by branch density (most branches first), read full source. Skip: POJOs, pure delegation, empty classes. For each method, list every distinct path:

Pattern Paths to Cover
if/else, ternary, &&/||, early return Both true and false outcomes
switch with N cases N+1 paths (include default)
for/while loop 0, 1, many iterations
try/catch Success + each exception type

2. Plan Minimal Tests

Group branches by execution path — one test hits multiple branches if they share the same flow:

process(x):
  if (x == null) return "empty";    // guard
  if (x < 0) return "negative";     // early exit
  return "positive";                // normal

→ 3 tests (not 6): null, -1, 1 — each activates a different set of branches.

Goal: minimum tests, maximum unique branch coverage.

3. Write Tests

  • Mock I/O and external systems only — never refactor source to "make testable"
  • Test private methods through public callers — never increase visibility
  • Use parameterized tests for same-logic-different-inputs
  • Assert the specific output each branch produces (not just assertNotNull)

4. Verify & Trim

# Run coverage tool — NEVER claim "done" without it:
mvn test jacoco:report    # Java
pytest --cov=src --cov-report=term-missing  # Python
jest --coverage           # JS/TS
go test -coverprofile=coverage.out && go tool cover -html=coverage.out  # Go
  • Red/yellow lines → add missing test
  • For each test: "If I delete this, does another test still cover these branches?" — if yes, delete it.

Quick Reference

Situation Approach
Private method with logic Test via public callers (all paths)
Void methods Assert side effects (DB writes, state changes)
Exception paths assertThrows + verify message
Deeply nested if Drill one level deeper per test, innermost first
Switch with enum One test per value + default

Common Mistakes

  • Modifying source → Never. Mock or use reflection as last resort.
  • Over-mocking → Mock only I/O. Test real logic through real call chains.
  • Under-asserting → assertNotNull(result) proves nothing. Assert the specific branch outcome.
  • Claiming coverage without running tool → Always run the tool. Always.
  • Skipping "hard to reach" branches → If you can't reach it, document it as dead code.

Red Flags — STOP

  • "I'll just make this private method public for testing"
  • "Let me refactor this first, then test"
  • "This branch is too hard to reach, I'll skip it"
  • Writing a test without knowing which branch it covers

All of these mean: Stop. Re-read the source. Map the branch. Write the test.

当前收录版本

1.0.0

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 针对单元测试覆盖率提升这一高频开发痛点,提供系统化方法论
  • 适用于多语言生态,具有广泛实用价值
触发精准90/100

亮点

  • 触发词精准完整,边界清晰,覆盖多种变体
结构规范95/100

亮点

  • 结构清晰,步骤明确,包含端到端示例和具体命令
执行可靠88/100

亮点

  • 提供主流语言覆盖率验证命令,强调不可跳过工具验证
证据可验 (前四项均值)90/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。