create-unit-test
プロジェクトのアーキテクチャやガイドライン(Robolectric、命名規則、ファイルの場所など)に従って、適切なユニットテストを作成し実行することで、コードの品質と信頼性を高めるSkill。
📜 元の英語説明(参考)
Create and run unit tests following the project's architecture and guidelines (Robolectric, naming, location).
🇯🇵 日本人クリエイター向け解説
プロジェクトのアーキテクチャやガイドライン(Robolectric、命名規則、ファイルの場所など)に従って、適切なユニットテストを作成し実行することで、コードの品質と信頼性を高めるSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o create-unit-test.zip https://jpskill.com/download/17217.zip && unzip -o create-unit-test.zip && rm create-unit-test.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/17217.zip -OutFile "$d\create-unit-test.zip"; Expand-Archive "$d\create-unit-test.zip" -DestinationPath $d -Force; ri "$d\create-unit-test.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
create-unit-test.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
create-unit-testフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
ユニットテストの作成
このスキルは、一貫性と正確性を保証するためのユニットテストの作成をガイドします。
ワークフロー
-
分析と計画:
- 目標: 何をテストする必要があるかを理解します。
- アクション: ソースコードを調べます。
- アクション: 「happy path」のケース(コア機能)を特定します。
- アクション: 可能性に基づいて、「error cases」と「edge cases」を特定します。
- アクション: 特に要求されない限り、実装の詳細を示唆しないでください。動作に焦点を当てます。
-
テストファイルのセットアップ:
- 命名:
[OriginalClassName]Test.kt。 - 場所:
[module]/src/test/java/[package/path]/。 - ランナー: Androidコンポーネントをテストする場合は、必ず Robolectricを使用してください。
- モック: MocksやパッチよりもFakesを作成することを推奨します。 Fakesが複雑すぎる場合にのみMocksを使用してください。
- 命名:
-
テストの実装:
- 明確で記述的なテストメソッドを記述します。
- 「Arrange-Act-Assert」パターンに従います。
- すべてのリソース(strings、themes)が適切にモックされているか、Robolectric経由で提供されていることを確認します。
-
テストの実行:
- コマンド:
./gradlew :[module]:testDebugUnitTest - 例:
./gradlew :database:testDebugUnitTest - ヒント: コミットする前に、
./gradlew testDebugUnitTestを実行して、すべてがパスすることを確認してください。
- コマンド:
-
失敗の処理:
- 目標: 問題を診断して修正します。
- アクション: テストが失敗した場合は、完全なエラーレポートを見つけます。
- パス:
[module]/build/test-results/testDebugUnitTest/TEST-[package.name.TestClassName].xml。 - 例:
app/build/test-results/testDebugUnitTest/TEST-com.anysoftkeyboard.janus.app.MainActivityTest.xml。
ガイドライン
- 一貫性: 常にテストを
testソースセットに配置し、androidTestには配置しないでください(特にインストルメンテーションテストを作成する場合を除きます。このスキルではまれです)。 - 信頼性: 不安定なテストは避けてください。 決定論的な動作を保証します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Create Unit Test
This skill guides the creation of unit tests to ensuring consistency and correctness.
Workflow
-
Analyze and Plan:
- Goal: Understand what needs testing.
- Action: Examine the source code.
- Action: Identify "happy path" cases (core functionality).
- Action: Identify "error cases" and "edge cases" based on likelihood.
- Action: Do not suggest implementation details unless asked; focus on behavior.
-
Setup Test File:
- Naming:
[OriginalClassName]Test.kt. - Location:
[module]/src/test/java/[package/path]/. - Runner: If testing Android components, you MUST use Robolectric.
- Mocking: Prefer creating Fakes over Mocks or patches. Use Mocks only if Fakes are too complex.
- Naming:
-
Implement Tests:
- Write clear, descriptive test methods.
- Follow the "Arrange-Act-Assert" pattern.
- Ensure all resources (strings, themes) are properly mocked or provided via Robolectric.
-
Run Tests:
- Command:
./gradlew :[module]:testDebugUnitTest - Example:
./gradlew :database:testDebugUnitTest - Tip: Before any commit, run
./gradlew testDebugUnitTestto ensure everything passes.
- Command:
-
Handle Failures:
- Goal: Diagnose and fix issues.
- Action: If a test fails, locate the full error report.
- Path:
[module]/build/test-results/testDebugUnitTest/TEST-[package.name.TestClassName].xml. - Example:
app/build/test-results/testDebugUnitTest/TEST-com.anysoftkeyboard.janus.app.MainActivityTest.xml.
Guidelines
- Consistency: Always place tests in the
testsource set, notandroidTest(unless specifically writing instrumentation tests, which is rare for this skill). - Reliability: Avoid flaky tests. Ensure deterministic behavior.