jpskill.com
📦 その他 コミュニティ

test-coverage-analyzer

テストカバレッジを分析して、テストされていないコード部分に対するテストケースを提案することで、テストの改善や網羅率向上を支援するSkill。

📜 元の英語説明(参考)

Analyzes test coverage gaps and suggests test cases for untested code paths. Use when user requests test improvements, coverage analysis, or wants to increase test coverage.

🇯🇵 日本人クリエイター向け解説

一言でいうと

テストカバレッジを分析して、テストされていないコード部分に対するテストケースを提案することで、テストの改善や網羅率向上を支援するSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o test-coverage-analyzer.zip https://jpskill.com/download/18111.zip && unzip -o test-coverage-analyzer.zip && rm test-coverage-analyzer.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/18111.zip -OutFile "$d\test-coverage-analyzer.zip"; Expand-Archive "$d\test-coverage-analyzer.zip" -DestinationPath $d -Force; ri "$d\test-coverage-analyzer.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して test-coverage-analyzer.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → test-coverage-analyzer フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
2

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

テストカバレッジアナライザー

このスキルは、テストカバレッジのギャップを特定し、コード品質を向上させるための具体的なテストケースを提案します。

このスキルを使用する場面

  • ユーザーがテストカバレッジの分析を依頼した場合
  • ユーザーがテストカバレッジの向上を希望する場合
  • ユーザーが不足しているテストの提案を要求した場合
  • コードカバレッジ率の向上に取り組んでいる場合
  • ユーザーが「カバレッジギャップ」、「テストされていないコード」、または「テストの提案」について言及した場合

手順

1. テストフレームワークの検出

プロジェクトで使用されているテストフレームワークを特定します。

JavaScript/TypeScript:

  • Jest: package.jsonjest があるか、jest.config.js があるか
  • Mocha: package.jsonmocha があるか、.mocharc があるか
  • Vitest: package.jsonvitest があるか、vitest.config.js があるか
  • Jasmine: package.jsonjasmine があるか

Python:

  • pytest: requirements.txtpytest があるか、pytest.ini があるか
  • unittest: 標準ライブラリ、テストファイルを確認
  • coverage.py: requirements.txtcoverage があるか

Ruby:

  • RSpec: Gemfilerspec があるか
  • Minitest: 標準ライブラリ

Go:

  • 組み込み: go test (カバレッジは go test -cover で)

Java:

  • JUnit: pom.xml または build.gradle で JUnit を探す
  • JaCoCo: カバレッジツール構成

Glob と Grep を使用して構成ファイルを検索します。

2. カバレッジレポートの特定

既存のカバレッジレポートを見つけます。

一般的な場所:

  • coverage/ ディレクトリ
  • .nyc_output/ (Node.js 用の NYC)
  • htmlcov/ (Python 用の coverage.py)
  • target/site/jacoco/ (Java 用の JaCoCo)
  • カバレッジファイル: lcov.info, coverage.json, .coverage

カバレッジレポートが存在しない場合:

  • ユーザーにカバレッジの実行を指示します: npm test -- --coverage, pytest --cov など
  • 分析前にレポートの生成を待ちます

3. カバレッジデータの解析

カバレッジ情報を抽出します。

lcov.info から:

  • カバーされた行数 vs 合計行数
  • カバーされた関数数 vs 合計関数数
  • カバーされたブランチ数 vs 合計ブランチ数
  • ファイルごとのカバーされていない行番号

coverage.json (Jest) から:

  • ステートメントカバレッジ率
  • ブランチカバレッジ率
  • 関数カバレッジ率
  • 行カバレッジ率
  • ファイルごとのカバーされていない行

.coverage (Python) から:

  • coverage report または coverage json を使用
  • 不足している行の範囲
  • 除外された行

HTML レポートから:

  • 要約統計を読み取る
  • カバレッジの低いファイルを特定する

4. カバレッジギャップの特定

テストが必要なファイル/関数を優先順位付けします。

優先度高:

  • カバレッジが 0% のビジネスロジック
  • パブリック API およびエクスポートされた関数
  • エラー処理パス (catch ブロック、エラーコールバック)
  • エッジケースと境界条件
  • クリティカルパス (認証、支払い、データ検証)

優先度中:

  • 部分的なカバレッジを持つユーティリティ関数
  • パブリック API によって呼び出されるプライベート関数
  • 構成および初期化コード

優先度低:

  • 単純なゲッター/セッター
  • 型定義
  • 自動生成されたコード
  • サードパーティのコード

5. テストされていないコードパスの分析

カバレッジギャップのある各ファイルについて:

  1. ソースファイルを読み取り、コード構造を理解します
  2. テストされていないコードを特定します:
    • カバーされていない行と行の範囲
    • テストされていない条件分岐 (if/else)
    • カバーされていないエラーハンドラー
    • 不足している関数カバレッジ
  3. 不足しているテストを分類します:
    • ハッピーパステスト
    • エラー/例外テスト
    • エッジケーステスト
    • 統合テスト

6. テストの提案の生成

カバレッジギャップごとに、具体的なテストケースを提案します。

形式:

File: src/utils/validator.js (42% coverage)

Missing Coverage:
- Lines 15-18: Email validation error path
- Lines 23-25: Empty input handling
- Lines 30-35: Edge case for special characters

Suggested Tests:
1. Test email validation with invalid format (covers lines 15-18)
2. Test validator with empty string input (covers lines 23-25)
3. Test special character handling in names (covers lines 30-35)

テストケースの詳細には以下を含める必要があります:

  • テストの説明
  • 入力データ
  • 期待される出力/動作
  • カバーされる行/ブランチ

7. テストスタブの作成 (オプション)

ユーザーが希望する場合は、テストファイルスタブを生成します。

  • 適切なテストフレームワークの構文を使用します
  • TODO コメント付きの describe/test ブロックを含めます
  • テスト構造の例を追加します
  • templates/test-template.js (または適切な拡張子) のテンプレートを参照します

例 (Jest):

describe('Validator', () => {
  describe('validateEmail', () => {
    it('should reject invalid email format', () => {
      // TODO: Test email validation error path (lines 15-18)
      const result = validateEmail('invalid-email');
      expect(result.valid).toBe(false);
    });

    it('should handle empty string input', () => {
      // TODO: Test empty input handling (lines 23-25)
    });
  });
});

8. カバレッジメトリクスの計算

要約統計を提供します。

  • 全体的なカバレッジ率
  • ファイル/ディレクトリ別のカバレッジ
  • テストのない関数/メソッド
  • カバレッジの低い重要なファイル
  • カバレッジの傾向 (履歴データが利用可能な場合)

9. 推奨事項の優先順位付け

提案を次の順序で並べ替えます。

  1. 影響: 重要なビジネスロジックを最初に
  2. リスク: リスクの高い領域 (セキュリティ、データ整合性)
  3. 複雑さ: 複雑なロジックにはより多くのテストが必要
  4. 容易さ: クイックウィン (高いカバレッジゲインのための簡単なテスト)

10. 出力形式

調査結果を明確で実行可能な形式で提示します。

Coverage Analysis Summary
=========================

Overall Coverage: 67%
- Statements: 65%
- Branches: 58%
- Functions: 72%
- Lines: 67%

Files Needing Attention (sorted by priority):

1. src/payment/processor.js (23% coverage) - HIGH PRIORITY
   - Missing: Error handling for payment failures
   - Missing: Retry logic tests
   - Missing: Transaction validation

2. src/auth/validator.js (45% coverage) - MEDIUM PRIORITY
   - Missing: Invalid token handling
   - Missing: Expired session tests

Suggested Test Cases:
[Detailed suggestions for each file]

ベストプラクティス

  1. 意味のあるカバレッジに焦点を当てる: 100% のカバレッジが常に必要とは限りません
  2. 実装ではなく、動作をテストする: 機能を検証するテストを提案します
  3. クリティカルパスを優先する: 認証、支払い、データ検証を最初に
  4. テストタイプを検討する: ユニット、イン
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Test Coverage Analyzer

This skill helps identify gaps in test coverage and suggests specific test cases to improve code quality.

When to Use This Skill

  • User asks to analyze test coverage
  • User wants to improve test coverage
  • User requests suggestions for missing tests
  • Working on increasing code coverage percentage
  • User mentions "coverage gaps", "untested code", or "test suggestions"

Instructions

1. Detect Testing Framework

Identify the testing framework(s) used in the project:

JavaScript/TypeScript:

  • Jest: jest in package.json or jest.config.js
  • Mocha: mocha in package.json or .mocharc
  • Vitest: vitest in package.json or vitest.config.js
  • Jasmine: jasmine in package.json

Python:

  • pytest: pytest in requirements.txt or pytest.ini
  • unittest: Standard library, check for test files
  • coverage.py: coverage in requirements.txt

Ruby:

  • RSpec: rspec in Gemfile
  • Minitest: Standard library

Go:

  • Built-in: go test (coverage via go test -cover)

Java:

  • JUnit: Look for JUnit in pom.xml or build.gradle
  • JaCoCo: Coverage tool configuration

Use Glob and Grep to find configuration files.

2. Locate Coverage Reports

Find existing coverage reports:

Common locations:

  • coverage/ directory
  • .nyc_output/ (NYC for Node.js)
  • htmlcov/ (coverage.py for Python)
  • target/site/jacoco/ (JaCoCo for Java)
  • Coverage files: lcov.info, coverage.json, .coverage

If no coverage report exists:

  • Guide user to run coverage: npm test -- --coverage, pytest --cov, etc.
  • Wait for report generation before analyzing

3. Parse Coverage Data

Extract coverage information:

From lcov.info:

  • Lines covered vs total
  • Functions covered vs total
  • Branches covered vs total
  • Uncovered line numbers by file

From coverage.json (Jest):

  • Statement coverage percentage
  • Branch coverage percentage
  • Function coverage percentage
  • Line coverage percentage
  • Uncovered lines per file

From .coverage (Python):

  • Use coverage report or coverage json
  • Missing line ranges
  • Excluded lines

From HTML reports:

  • Read summary statistics
  • Identify files with low coverage

4. Identify Coverage Gaps

Prioritize files/functions that need testing:

High priority:

  • Business logic with 0% coverage
  • Public APIs and exported functions
  • Error handling paths (catch blocks, error callbacks)
  • Edge cases and boundary conditions
  • Critical paths (authentication, payment, data validation)

Medium priority:

  • Utility functions with partial coverage
  • Private functions called by public APIs
  • Configuration and initialization code

Lower priority:

  • Simple getters/setters
  • Type definitions
  • Auto-generated code
  • Third-party code

5. Analyze Untested Code Paths

For each file with coverage gaps:

  1. Read the source file to understand the code structure
  2. Identify untested code:
    • Uncovered lines and line ranges
    • Untested conditional branches (if/else)
    • Uncovered error handlers
    • Missing function coverage
  3. Categorize missing tests:
    • Happy path tests
    • Error/exception tests
    • Edge case tests
    • Integration tests

6. Generate Test Suggestions

For each coverage gap, suggest specific test cases:

Format:

File: src/utils/validator.js (42% coverage)

Missing Coverage:
- Lines 15-18: Email validation error path
- Lines 23-25: Empty input handling
- Lines 30-35: Edge case for special characters

Suggested Tests:
1. Test email validation with invalid format (covers lines 15-18)
2. Test validator with empty string input (covers lines 23-25)
3. Test special character handling in names (covers lines 30-35)

Test case details should include:

  • Test description
  • Input data
  • Expected output/behavior
  • Lines/branches covered

7. Create Test Stubs (Optional)

If user wants, generate test file stubs:

  • Use appropriate test framework syntax
  • Include describe/test blocks with TODO comments
  • Add example test structure
  • Reference the template in templates/test-template.js (or appropriate extension)

Example (Jest):

describe('Validator', () => {
  describe('validateEmail', () => {
    it('should reject invalid email format', () => {
      // TODO: Test email validation error path (lines 15-18)
      const result = validateEmail('invalid-email');
      expect(result.valid).toBe(false);
    });

    it('should handle empty string input', () => {
      // TODO: Test empty input handling (lines 23-25)
    });
  });
});

8. Calculate Coverage Metrics

Provide summary statistics:

  • Overall coverage percentage
  • Coverage by file/directory
  • Functions/methods without tests
  • Critical files with low coverage
  • Coverage trend (if historical data available)

9. Prioritize Recommendations

Order suggestions by:

  1. Impact: Critical business logic first
  2. Risk: High-risk areas (security, data integrity)
  3. Complexity: Complex logic needs more tests
  4. Ease: Quick wins (simple tests for high coverage gain)

10. Output Format

Present findings in a clear, actionable format:

Coverage Analysis Summary
=========================

Overall Coverage: 67%
- Statements: 65%
- Branches: 58%
- Functions: 72%
- Lines: 67%

Files Needing Attention (sorted by priority):

1. src/payment/processor.js (23% coverage) - HIGH PRIORITY
   - Missing: Error handling for payment failures
   - Missing: Retry logic tests
   - Missing: Transaction validation

2. src/auth/validator.js (45% coverage) - MEDIUM PRIORITY
   - Missing: Invalid token handling
   - Missing: Expired session tests

Suggested Test Cases:
[Detailed suggestions for each file]

Best Practices

  1. Focus on meaningful coverage: 100% coverage isn't always necessary
  2. Test behavior, not implementation: Suggest tests that verify functionality
  3. Prioritize critical paths: Authentication, payments, data validation first
  4. Consider test types: Unit, integration, and e2e where appropriate
  5. Check existing tests: Don't suggest tests that already exist
  6. Realistic test data: Use plausible inputs in examples
  7. Coverage thresholds: Suggest minimum coverage targets (e.g., 80%)

Running Coverage Reports

Provide commands based on detected framework:

Jest: npm test -- --coverage or jest --coverage Vitest: npm test -- --coverage or vitest run --coverage Mocha + NYC: nyc mocha pytest: pytest --cov=src --cov-report=html Go: go test -cover ./... or go test -coverprofile=coverage.out JUnit + JaCoCo: mvn test jacoco:report

Supporting Files

  • scripts/parse-coverage.sh: Helper script to extract coverage data
  • templates/test-template.js: Test file template for JavaScript
  • templates/test-template.py: Test file template for Python
  • templates/test-template.go: Test file template for Go

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。