Test Double
Test Double
Ein Test Double vertritt ein echtes Systemteil. Stubs, Fakes, Spies und Mocks geben Kontrolle oder Sichtbarkeit.
Ein weiteres Beispiel
Ein Versandtest nutzt einen fiktiven Versanddienst mit festen Preisen. Ein Spy prüft, ob eine angenommene Bestellung genau eine Abholung plant.
Hauptteile
- 01Code or behavior under test
- 02Observable evidence
- 03Coverage, failure, and recovery
Verwenden Sie es, wenn
Wähle das einfachste Double, das eine Grenze stabilisiert oder einen wichtigen Vertrag aufdeckt.
Nutze es nicht, wenn
Mock nicht deinen eigenen Call-Graphen, kopiere keine Dependency-Bugs und ersetze keinen wertvollen Integration-Test.
In Code verwendeter Name
stub / fake / spy / mock Vor dem Ausliefern
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 (Test Double). User context: Ein Versandtest nutzt einen fiktiven Versanddienst mit festen Preisen. Ein Spy prüft, ob eine angenommene Bestellung genau eine Abholung plant. Validation approach: Test Double (Test Double). Why it fits: Wähle das einfachste Double, das eine Grenze stabilisiert oder einen wichtigen Vertrag aufdeckt. Do not use it when: Mock nicht deinen eigenen Call-Graphen, kopiere keine Dependency-Bugs und ersetze keinen wertvollen Integration-Test. 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): Kein einziger offizieller Standard kontrolliert den gesamten Begriff. Seine Bedeutung kann sich zwischen Teams, Plattformen oder Frameworks ändern. Unknowns to confirm: Release gate, environment, prepared test data, allowed error, time budget, owner, and flaky-test rule.
Diese Anfrage prüfen
Review how Test Double (Test Double) is used now. Definition: Ein Test Double vertritt ein echtes Systemteil. Stubs, Fakes, Spies und Mocks geben Kontrolle oder Sichtbarkeit. 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.