Communitygithub.com

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

テストカバレッジのギャップを分析し、未テストのコードパスに対するテストケースを提案します。ユーザーがテストの改善やカバレッジ分析を依頼した際に使用します。

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

このスキルは、コードベースのテストカバレッジを分析し、カバレッジのギャップを特定して具体的なテストケースを提案するAIエージェント向けのツールです。開発者がテスト品質を向上させたいとき、カバレッジレポートを解析し、未テストのビジネスロジックやエラーハンドリング、エッジケースを優先的に特定します。対応するテストフレームワークは、JavaScript/TypeScript(Jest、Mocha、Vitest、Jasmine)、Python(pytest、unittest)、Ruby(RSpec、Minitest)、Go(go test)、Java(JUnit、JaCoCo)など多岐にわたります。カバレッジレポート(lcov.info、coverage.json、.coverageなど)を解析し、カバレッジ率をファイル・関数・ブランチ単位で算出。重要なコードパスから優先的にテスト提案を行い、必要に応じてテストファイルのスタブを生成します。最終的には、全体的なカバレッジ統計と改善優先順位をわかりやすく出力します。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazydubya/test-coverage-analyzer

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

テストカバレッジアナライザー は何をしますか?

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

このスキルを使用するタイミング

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

手順

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

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

JavaScript/TypeScript:

  • Jest: package.json 内の jest または jest.config.js
  • Mocha: package.json 内の mocha または .mocharc
  • Vitest: package.json 内の vitest または vitest.config.js
  • Jasmine: package.json 内の jasmine

Python:

  • pytest: requirements.txt 内の pytest または pytest.ini
  • unittest: 標準ライブラリ、テストファイルを確認
  • coverage.py: requirements.txt 内の coverage

Ruby:

  • RSpec: Gemfile 内の rspec
  • 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 から呼び出されるプライベート関数
  • 設定および初期化コード

低優先度:

  • 単純な getter/setter
  • 型定義
  • 自動生成コード
  • サードパーティコード

5. 未テストコードパスの分析

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

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

6. テスト提案の生成

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

形式:

ファイル: src/utils/validator.js(42% カバレッジ)

不足しているカバレッジ:
- 15~18行目: メール検証のエラーパス
- 23~25行目: 空入力の処理
- 30~35行目: 特殊文字のエッジケース

提案テスト:
1. 無効な形式でメール検証をテスト(15~18行目をカバー)
2. 空文字列入力でバリデータをテスト(23~25行目をカバー)
3. 名前の特殊文字処理をテスト(30~35行目をカバー)

テストケースの詳細には以下を含める:

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

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

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

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

例(Jest):

describe('Validator', () => {
  describe('validateEmail', () => {
    it('should reject invalid email format', () => {
      // TODO: メール検証のエラーパスをテスト(15~18行目)
      const result = validateEmail('invalid-email');
      expect(result.valid).toBe(false);
    });

    it('should handle empty string input', () => {
      // TODO: 空入力の処理をテスト(23~25行目)
    });
  });
});

8. カバレッジ指標の計算

サマリー統計を提供します。

  • 全体のカバレッジ率
  • ファイル/ディレクトリ別のカバレッジ
  • テストがない関数/メソッド
  • カバレッジが低いクリティカルファイル
  • カバレッジのトレンド(過去データがある場合)

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

提案を以下の順序で並べます。

  1. 影響: クリティカルなビジネスロジックを最優先
  2. リスク: 高リスク領域(セキュリティ、データ整合性)
  3. 複雑性: 複雑なロジックはより多くのテストが必要
  4. 容易性: 即効性のあるもの(高カバレッジ向上のための簡単なテスト)

10. 出力形式

発見事項を明確で実行可能な形式で提示します。

カバレッジ分析サマリー
=========================

全体カバレッジ: 67%
- ステートメント: 65%
- ブランチ: 58%
- 関数: 72%
- 行: 67%

注意が必要なファイル(優先順位順):

1. src/payment/processor.js(23% カバレッジ)- 高優先度
   - 不足: 支払い失敗のエラーハンドリング
   - 不足: リトライロジックのテスト
   - 不足: トランザクション検証

2. src/auth/validator.js(45% カバレッジ)- 中優先度
   - 不足: 無効なトークンの処理
   - 不足: 期限切れセッションのテスト

提案テストケース:
[各ファイルの詳細な提案]

ベストプラクティス

  1. 意味のあるカバレッジに焦点を当てる: 100% カバレッジが常に必要とは限らない
  2. 実装ではなく振る舞いをテストする: 機能を検証するテストを提案する
  3. クリティカルパスを優先する: 認証、支払い、データ検証を最初に
  4. テストの種類を考慮する: 適宜、単体テスト、結合テスト、E2E テストを
  5. 既存のテストを確認する: すでに存在するテストは提案しない
  6. 現実的なテストデータ: 例では妥当な入力を使う
  7. カバレッジしきい値: 最低限のカバレッジ目標(例: 80%)を提案する

カバレッジレポートの実行

検出されたフレームワークに基づいてコマンドを提供します。

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

サポートファイル

  • scripts/parse-coverage.sh: カバレッジデータ抽出のヘルパースクリプト
  • templates/test-template.js: JavaScript 用テストファイルテンプレート
  • templates/test-template.py: Python 用テストファイルテンプレート
  • templates/test-template.go: Go 用テストファイルテンプレート

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

関連スキル