본문으로 건너뛰기
cccskills
무료GitHub에 공개

acc-analyze-test-coverage

Analyzes PHP codebase for test coverage gaps. Detects untested classes, methods, branches, exception paths, and edge cases. Provides actionable recommendations.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md6.3 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Test Coverage Analysis

Analyzes PHP codebase to identify untested code and coverage gaps.

Detection Patterns

1. Classes Without Tests

# Find all PHP classes in src/
Glob: src/**/*.php

# Find all test files
Glob: tests/**/*Test.php

# Compare: class Foo in src/ should have FooTest in tests/

Pattern Matching:

src/Domain/User/User.php → tests/Unit/Domain/User/UserTest.php
src/Application/PlaceOrder/PlaceOrderHandler.php → tests/Unit/Application/PlaceOrder/PlaceOrderHandlerTest.php

2. Methods Without Tests

// For each public method in class
Grep: "public function [a-z]" --glob "src/**/*.php"

// Check if test method exists
Grep: "test_methodName" --glob "tests/**/*Test.php"

Detection Logic:

Class: Order
├── confirm() → test_confirm_* exists? ✅/❌
├── cancel() → test_cancel_* exists? ✅/❌
├── ship() → test_ship_* exists? ✅/❌
└── addItem() → test_addItem_* / test_add_item_* exists? ✅/❌

3. Branches Not Covered

If/Else Branches:

// Source code
public function process(Order $order): void
{
    if ($order->isPending()) {     // Branch 1: pending
        $this->processPending($order);
    } elseif ($order->isConfirmed()) { // Branch 2: confirmed
        $this->processConfirmed($order);
    } else {                       // Branch 3: other
        throw new InvalidStateException();
    }
}

// Required tests:
// - test_process_when_pending_*
// - test_process_when_confirmed_*
// - test_process_when_other_throws_exception

Switch Statements:

// Source code
match ($status) {
    'pending' => $this->handlePending(),
    'confirmed' => $this->handleConfirmed(),
    'shipped' => $this->handleShipped(),
    default => throw new UnexpectedValueException(),
};

// Required tests: one per case + default

4. Exception Paths

// Detect throw statements
Grep: "throw new" --glob "src/**/*.php"

// Each throw should have corresponding test with expectException

Example:

// Source
public function withdraw(Money $amount): void
{
    if ($amount->greaterThan($this->balance)) {
        throw new InsufficientFundsException();  // Line 15
    }
}

// Required test
public function test_withdraw_throws_for_insufficient_funds(): void
{
    $this->expectException(InsufficientFundsException::class);
    // ...
}

5. Edge Cases

TypeValues to TestDetection
Nullnull inputParameters without type hint or nullable
Empty[], '', 0Collection/string/numeric parameters
Boundarymin, max, min-1, max+1Constants, validation limits
Unicode'émoji 🎉'String parameters
ConcurrentRace conditionsShared state, repositories

Detection Patterns:

// Nullable parameters
Grep: "\?[A-Z]" --glob "src/**/*.php"  // ?Type
Grep: "null\|" --glob "src/**/*.php"   // Type|null

// Collections
Grep: "array \$" --glob "src/**/*.php"
Grep: "iterable" --glob "src/**/*.php"

// Numeric limits
Grep: "const MAX_" --glob "src/**/*.php"
Grep: "const MIN_" --glob "src/**/*.php"

Analysis Process

Phase 1: Inventory

  1. List all production classes:

    Glob: src/**/*.php
    
  2. List all test classes:

    Glob: tests/**/*Test.php
    
  3. Build mapping:

    ProductionClass → [TestClass, TestClass]
    

Phase 2: Class Coverage

For each production class:

  1. Check if corresponding test exists
  2. Calculate: covered_classes / total_classes * 100

Phase 3: Method Coverage

For each public method:

  1. Extract method names from production code
  2. Search for test_{method} patterns in tests
  3. Calculate: tested_methods / total_methods * 100

Phase 4: Branch Coverage

For each conditional:

  1. Count branches (if/elseif/else, match cases)
  2. Search for tests covering each branch
  3. Report uncovered branches

Phase 5: Edge Cases

  1. Identify nullable/optional parameters
  2. Identify collections
  3. Identify numeric limits
  4. Check if edge case tests exist

Output Format

# Test Coverage Analysis Report

## Summary

| Metric | Value | Target |
|--------|-------|--------|
| Class Coverage | 75% | 90% |
| Method Coverage | 60% | 80% |
| Branch Coverage | 45% | 70% |

## Untested Classes

| Class | Location | Priority |
|-------|----------|----------|
| `PaymentProcessor` | src/Domain/Payment/ | High |
| `EmailNotifier` | src/Infrastructure/ | Medium |

## Untested Methods

| Class | Method | Reason |
|-------|--------|--------|
| `Order` | `splitShipment()` | No test found |
| `User` | `resetPassword()` | Only happy path tested |

## Uncovered Branches

| File | Line | Branch | Missing Test |
|------|------|--------|--------------|
| Order.php | 45 | else (cancelled) | test_ship_when_cancelled |
| User.php | 23 | null check | test_with_null_email |

## Missing Edge Cases

| Class | Method | Edge Case |
|-------|--------|-----------|
| `Cart` | `addItem()` | Empty cart, max items |
| `Money` | `add()` | Zero amount, overflow |

## Action Items

### Critical (Must Have)
1. Add `PaymentProcessorTest` — handles money
2. Add `test_order_ship_when_cancelled` — business rule

### High Priority
1. Add null checks for `User::resetPassword()`
2. Add boundary tests for `Cart::addItem()`

### Recommended Skills

| Gap | Skill | Action |
|-----|-------|--------|
| Missing unit test | `acc-create-unit-test` | Generate test class |
| Missing integration test | `acc-create-integration-test` | Generate DB test |
| Need test data | `acc-create-test-builder` | Generate builder |

Severity Levels

LevelCoverageAction
Critical<50%Immediate attention
Warning50-70%Prioritize improvement
Good70-90%Monitor and maintain
Excellent>90%Focus on edge cases

Integration with Generator

After analysis, recommend using:

  • acc-create-unit-test — for missing unit tests
  • acc-create-integration-test — for missing integration tests
  • acc-create-test-builder — for complex test data
  • acc-create-mock-repository — for repository tests

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Master backend architectures, REST API design, microservices, and server-side development across multiple languages. Use this as a central index to access specialized sub-skills.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

在每次回复中使用固定前缀并列出本次实际参考的指令/文件,便于校验是否遵循上下文与规则。

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Automate 21risk tasks via Rube MCP (Composio). Always search tools first for current schemas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Automate 2chat tasks via Rube MCP (Composio). Always search tools first for current schemas.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

[00] META. Orchestrate skills into dynamic chains for complex tasks. Analyzes the task, discovers available skills, builds an optimal chain, explains why each skill is needed, and executes step-by-step with user confirmation. Use for any complex task requiring multiple thinking/research/analysis steps. Triggers on "plan this", "how to approach", "what's the strategy", "build a plan", or any multi-step problem requiring skill orchestration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

MikeCheng1208/BattleTree22026년 7월 22일 업데이트

MikeCheng1208의 스킬 모두 보기

이 스킬의 문제 신고