Test Double
テストダブル
テストダブルは、本物のシステムの代わりです。スタブ、フェイク、スパイ、モックを使うと、動きをコントロールしたり、中身を見えるようにしたりできます。
もう一つの例
配送テストでは、料金が決まっている架空の運送会社を使います。スパイを使って、注文が受け付けられたら集荷が1回だけ予約されているか確認します。
主な部分
- 01Code or behavior under test
- 02Observable evidence
- 03Coverage, failure, and recovery
以下の場合に使用します
境界を安定させるか、重要な契約を明らかにする最も簡単なダブルを選んでください。
以下の場合は使用しないでください
自分の呼び出しグラフをモックしたり、依存関係のバグをコピーしたり、貴重な統合テストを置き換えたりしてはいけません。
コードで使用する名前
stub / fake / spy / mock 出荷前に
Check the environment and prepared test data (fixture). Define a result you can observe, failure and edge cases, isolation, stable inputs, useful error details, and cleanup. Set a time budget, owner, and flaky-test rule.
Outcome:Complete the task with テストダブル (Test Double)。 User context:配送テストでは、料金が決まっている架空の運送会社を使います。スパイを使って、注文が受け付けられたら集荷が1回だけ予約されているか確認します。 Validation approach:テストダブル (Test Double)。 Why it fits:境界を安定させるか、重要な契約を明らかにする最も簡単なダブルを選んでください。 Do not use it when:自分の呼び出しグラフをモックしたり、依存関係のバグをコピーしたり、貴重な統合テストを置き換えたりしてはいけません。 Test requirements: Name the system and test environment. Define prepared test data, other inputs, and the result you can observe. Include failure and edge cases, allowed error, isolation, and cleanup. Test operations: Make failures easy to diagnose. Control random or changing inputs. Name an owner. Keep the test fast and simple enough for its release gate. Acceptance criteria: The test fails for the known bug and passes after the fix. It repeats in the target environment, gives useful evidence, and does not expose or change unrelated data. Evidence and limits (evidence boundary):単一の公式標準が全体の用語を管理するわけではありません。その意味はチーム、プラットフォーム、またはフレームワークによって変わる可能性があります。 Unknowns to confirm: Release gate, environment, prepared test data, allowed error, time budget, owner, and flaky-test rule.
このリクエストを確認する
Review how テストダブル (Test Double) is used now. Definition: テストダブルは、本物のシステムの代わりです。スタブ、フェイク、スパイ、モックを使うと、動きをコントロールしたり、中身を見えるようにしたりできます。 Release checks: Check the environment and prepared test data (fixture). Define a result you can observe, failure and edge cases, isolation, stable inputs, useful error details, and cleanup. Set a time budget, owner, and flaky-test rule. Before changing code, list the evidence, gaps, severity, and the smallest safe fix.