add-missing-unit-test

作成者: flutter

現在ユニットテストがないクラスに新しいユニットテストを追加するか、既存のテストファイルに新しいテストケースを追加し、Koverで改善を検証します。

npx skills add https://github.com/flutter/flutter-intellij --skill add-missing-unit-test

Skill: Add Missing Unit Test

You are tasked with adding a new unit test for a class that currently lacks one, or adding a new test case to an existing test file, to improve code coverage and reliability.

Objective

Add a new unit test for a class that currently lacks one, or add a new test case to an existing test file, to improve code coverage and reliability.

Workflow Instructions

1. Identify Target

  • Choose a class in src/ that has complex logic but logic coverage is missing or incomplete.

2. Establish Baseline

  • Run ./gradlew testClasses to compile all sources (production and test) and ensure the project is in a valid state.
  • Run ./gradlew verifyPlugin to ensure no plugin verification issues exist.
  • Run ./gradlew test (or specific test if it exists) to establish current pass/fail status.
  • Run tests with Kover (./gradlew koverHtmlReport or ./gradlew koverXmlReport) to determine current coverage percentage for target class.

3. Implement Test

  • Create a new test class ([ClassName]Test) in testSrc/ if it doesn't exist.
  • Add test cases to cover specific methods, edge cases, and branches.
  • Ensure the test follows project testing conventions (naming, mocking, assertions).

4. Verify

  • Run ./gradlew testClasses to ensure new test compiles.
  • Run new test (and related tests) to ensure it passes.
  • Run ./gradlew verifyPlugin to ensure no regressions in plugin verification.
  • Run Kover again to confirm coverage improvement.

5. Report & Review

  • Summarize test added and coverage improvement.
  • Test Location: Explicitly state where in the IDE user should go to test changed functionality (e.g., "Run the new test file [TestFileName]").
  • Action: Ask user to review new test closely. Validate that code being tested is actively used (e.g., check that it is not dead code/0 references).
  • Do not commit or push.
  • Provide a suggested Git commit message, explicitly including the Kover coverage improvement:
    • Example Pattern: Add unit tests for [Class Name]. Coverage verified using Kover. Coverage improvement: [Class Name]: ~[X]% line coverage ([Y] covered, [Z] uncovered).

flutterのその他のスキル

dart-modern-features
flutter
モダナイゼーションの候補を見つけるには:
flutter-fix-layout-issues
flutter
Flutterのレイアウトエラー(オーバーフロー、制約の無限大)をDartとFlutter MCPツールを使って修正します。「RenderFlex overflowed」「Vertical…」といった問題に対処する際に使用します。
adding-release-notes
flutter
DevToolsのリリースノートにユーザー向けの変更説明を追加します。NEXT_RELEASE_NOTES.mdファイルに改善点、修正、新機能を文書化する際に使用します。
reviewing-devtools-prs
flutter
DevToolsリポジトリ固有のPRレビューワークフローで、DevToolsのスタイルガイドラインと一般的なレビューパターンを適用します。プルリクエストをレビューする際に使用します。
dart-use-primary-constructors
flutter
ユーザーがDartで構文的・意味的に正しいプライマリコンストラクタを記述できるよう支援し、新しいコンストラクタ構文、空ボディのセミコロン構文への移行・使用を支援します、…
code-documentation
flutter
効果的なコードドキュメントを書くためのガイド。docstring、JSDoc、dartdoc、実装コメントを含む。新しいコードを書く際や追加する際にこのスキルを使用する。
api-review
flutter
指定されたコードを標準的なAPI設計ガイドラインに照らしてレビューします。ユーザーがAPIレビューを依頼した場合や、コードをAPI設計に照らして確認したい場合にこのスキルを使用します。
flutter-accessibility
flutter
FlutterアプリにWCAG 2およびEN 301 549アクセシビリティ基準とアダプティブレイアウトを実装します。モバイル、ウェブ、デスクトッププラットフォーム全体で、セマンティックアノテーション、タップターゲットサイズ(最小48x48 dp)、テキストコントラスト比(小テキストは4.5:1、大テキストは3:1)を適用します。ウェブセマンティクスの初期化、インタラクティブウィジェットのラッピング、画面サイズに基づくレイアウト切り替え、キーボード/マウス入力処理のための決定ロジックを提供します。FocusTraversalGroupによるフォーカストラバーサル管理を含みます...