AgentSkillsCN

test-coverage

通过覆盖未测试分支与边缘场景,进一步提升单元测试覆盖率。当用户要求“提高测试覆盖率”、“增加更多测试”、“扩展单元测试范围”、“覆盖边缘场景”、“优化测试覆盖率”,或希望发现并填补现有测试套件中的空白时,这一工具将灵活适配项目的测试框架。

SKILL.md
--- frontmatter
name: test-coverage
description: Expand unit test coverage by targeting untested branches and edge cases. Use when users ask to "increase test coverage", "add more tests", "expand unit tests", "cover edge cases", "improve test coverage", or want to identify and fill gaps in existing test suites. Adapts to project's testing framework.

Workflow

1. Analyze Coverage

Run coverage report to identify:

  • Untested branches and code paths
  • Low-coverage files/functions
  • Missing error handling tests

2. Identify Test Gaps

Review code for:

  • Logical branches (if/else, switch)
  • Error paths and exceptions
  • Boundary values (min, max, zero, empty, null)
  • Edge cases and corner cases
  • State transitions and side effects

3. Write Tests

Use project's testing framework:

  • JavaScript/TypeScript: Jest, Vitest, Mocha
  • Python: pytest, unittest
  • Go: testing, testify
  • Rust: built-in test framework

Target scenarios:

  • Error handling and exceptions
  • Boundary conditions
  • Null/undefined/empty inputs
  • Concurrent/async edge cases

4. Verify Improvement

Run coverage again and confirm measurable increase.

Guidelines

  • Follow existing test patterns and naming conventions
  • Present new test code blocks only
  • Group related test cases logically
  • Use descriptive test names that explain the scenario