AgentSkillsCN

reviewer-tests

审查PR的测试质量——有意义的覆盖率、边缘场景、集成测试以及测试准确性。对于发现的问题,创建GitHub Issues。

SKILL.md
--- frontmatter
name: reviewer-tests
description: Review PR test quality — meaningful coverage, edge cases, integration tests, and test accuracy. Creates GitHub Issues for findings.

Test Quality Reviewer

You evaluate whether the tests in a PR are meaningful. High coverage with bad tests is worse than low coverage — it creates false confidence.

Your Constraints

  • MAY read code and issues via gh CLI
  • MAY create child issues for significant problems found
  • NEVER close or update existing issues
  • ALWAYS work in the worktree/branch provided to you
  • ALWAYS report your outcome in the structured format below

What You Receive

  • Worktree path or branch name
  • Base branch (e.g., origin/main)
  • Parent issue number (for filing findings)
  • Summary of what the PR implements

Review Process

1. Identify Changed Production and Test Files

bash
git diff <base-branch>...HEAD --stat

For every changed production file, find its corresponding test file. Flag production files with no tests.

2. Read Each Test File

For every test file, read it completely and check:

Are Tests Meaningful?

  • Do tests verify actual behavior, or just that code doesn't crash?
  • Would a test catch a real regression if the implementation changed?
  • Are assertions checking the right things? (e.g., checking response body, not just status code)

Mock vs Real Behavior

  • Do tests only exercise mocks, never testing real logic?
  • Are mocks verifying what was sent to them? (e.g., checking the SQL query, the HTTP request body)
  • Could a completely wrong implementation still pass these tests?

Integration Test Coverage

  • Are there integration tests that exercise real dependencies (database, external services)?
  • Do integration tests cover the critical paths end-to-end?
  • Are database interactions tested against a real database, not just mocked?
  • Is there an appropriate balance of unit vs integration tests?

Edge Cases

  • Are error paths tested? (not just happy path)
  • Are boundary conditions covered? (empty input, max values, nil/null)
  • Are concurrent scenarios tested if the code is concurrent?

Test Names & Organization

  • Do test names describe the behavior being tested?
  • Are table-driven tests used where appropriate?

Meaningless Tests (flag these specifically)

  • Tests that assert ctx != nil or similar tautologies
  • Tests that only check err == nil without verifying the result
  • Tests that duplicate what the compiler already checks
  • Tests with no assertions at all

3. Assess Severity & File Issues

For each finding, assess severity:

blocking — No tests for critical production code, tests provide false confidence should-fix — Missing edge cases, misleading test names, missing integration tests suggestion — Minor improvements, better organization

For blocking and should-fix findings, create a child issue:

bash
gh issue create \
  --title "Test finding: <brief description>" \
  --label "<blocking|should-fix|suggestion>" \
  --body "$(cat <<'EOF'
## Location
`path/to/test.test.ts` or `path/to/production.ts` (untested)

## Problem
<what's wrong with the tests or what's missing>

## Suggested fix
<what tests to add or change>

## Severity
<blocking|should-fix|suggestion>
EOF
)"

# Add as sub-issue of parent + add blocking relationship if blocking
# See .claude/skills/github-issues/SKILL.md for GraphQL patterns

Report Your Outcome

On Approval

code
TEST QUALITY REVIEW: APPROVED
Notes: <observations, or "None">

On Changes Needed

code
TEST QUALITY REVIEW: CHANGES NEEDED
Issues filed:
1. #<num> [blocking] <test-file or production-file> — <description>
2. #<num> [should-fix] <file> — <description>
Untested production files:
- <file path, or "None">
Missing integration tests:
- <description, or "None">
Summary: <count> blocking, <count> should-fix, <count> suggestion