Flutter App のテスト実行・静的解析・フォーマット・テスト記述ガイド
Scanned 5/27/2026
Install via CLI
openskills install K9i-0/ccpocket---
name: test-flutter
description: Flutter App のテスト実行・静的解析・フォーマット・テスト記述ガイド
disable-model-invocation: true
allowed-tools: Bash(flutter:*), Bash(dart:*), Read, Glob, Grep
---
# Flutter App テスト
## 実行手順
以下を順番に実行し、全てパスすることを確認する。
### 1. 静的解析
```bash
dart analyze apps/mobile
```
warning 以上は修正する。info レベルは必要に応じて対応。
**MCP代替:** `mcp__dart-mcp__analyze_files` でも実行可能だが、CLI推奨。
### 2. フォーマット
```bash
dart format apps/mobile
```
### 3. ユニットテスト
```bash
cd apps/mobile && flutter test
```
特定ファイルのみ:
```bash
cd apps/mobile && flutter test test/<filename>_test.dart
```
**MCP代替:** `mcp__dart-mcp__run_tests` でも実行可能だが、CLI推奨。
MCP版はDTD接続不要な操作のため、CLIの方が効率的。
## テスト記述規約
### ファイル配置・命名
- テストファイルは `apps/mobile/test/` に配置
- 命名: `<対象の概念>_test.dart`
- ウィジェットテスト例: `approval_bar_test.dart`, `chat_input_bar_test.dart`
- ロジックテスト例: `chat_message_handler_test.dart`
### import
```dart
import 'package:flutter_test/flutter_test.dart';
import 'package:ccpocket/...';
```
### テスト構造
```dart
void main() {
group('対象クラスまたは機能', () {
test('動作の説明', () {
// ロジックテスト
expect(actual, expected);
});
testWidgets('UI動作の説明', (tester) async {
// ウィジェットテスト
await tester.pumpWidget(MaterialApp(home: TargetWidget()));
expect(find.text('expected'), findsOneWidget);
});
});
}
```
- `group` で対象機能ごとにグルーピング
- ロジックテストは `test()`、UI テストは `testWidgets()` を使い分ける
- `setUp()` でテスト前の共通初期化を行う
### テスト対象の方針
- **ウィジェットテスト**: 画面の表示・インタラクション検証
- `pumpWidget` でウィジェット構築 → `find` で要素確認 → `tap`/`enterText` で操作
- **ロジックテスト**: サービス・ハンドラーの振る舞い検証
- 純粋なDartクラスのメソッド呼び出しと結果確認
- WebSocket通信やBridge接続のモックが必要なテストは避ける (E2E領域)
### 既存テストファイル一覧
- `approval_bar_test.dart` — 承認バーUI
- `ask_user_question_widget_test.dart` — AskUserQuestion UI
- `chat_input_bar_test.dart` — チャット入力バーUI
- `chat_message_handler_test.dart` — メッセージハンドラーロジック
- `gallery_screen_test.dart` — ギャラリー画面
- `home_screen_test.dart` — ホーム画面
- `plan_mode_test.dart` — プランモードUI
- `session_card_test.dart` — セッションカードUI
- `slash_command_test.dart` — スラッシュコマンドUI
- `tool_result_bubble_test.dart` — ツール結果表示
- `tool_use_tile_test.dart` — ツール使用タイル表示
No comments yet. Be the first to comment!
Use this skill when developing or maintaining browser extension code in the `browser/` directory, including Chrome/Firefox/Edge compatibility, content scripts, background scripts, or i18n updates.
SEO optimization with keyword analysis, readability assessment, technical validation, content quality. Use for search rankings, blog posts, content audits, or encountering keyword density, readability scores, meta tags, schema markup errors.
Python backend development expertise for FastAPI, security patterns, database operations, Upstash integrations, and code quality. Use when: (1) Building REST APIs with FastAPI, (2) Implementing JWT/OAuth2 authentication, (3) Setting up SQLAlchemy/async databases, (4) Integrating Redis/Upstash caching, (5) Refactoring AI-generated Python code (deslopification), (6) Designing API patterns, or (7) Optimizing backend performance.
Drive the full internationalization journey for a project — detect the stack, recommend a library, set up the chosen library, wrap existing strings, and optionally connect a translation platform. Use when the user asks to add or configure i18n, internationalization, localization, multi-language support, or translations — including when they explicitly mention LinguiJS, Lingui, next-intl, "wrap strings", "find hardcoded text", "make my app translatable", or "set up translations". Triggers on g...
PTES-aligned adversarial security audit for backend, frontend, and mobile applications. Produces a CVSS-scored Hacker Report with verified PoCs and phased remediation.