Mocking (EN)
TermTechnique for replacing dependencies with controlled doubles
Mocking in Software Testing
Mocking is a technique in software testing where dependencies of a component are replaced by special objects called doubles. These mocks provide predefined responses to method calls without requiring actual external resources like databases or APIs to be called. Through mocking, tests can be executed in isolation, quickly and reliably, as they don't depend on external systems.
Architecture
flowchart LR A[Test] --> B[Komponente unter Test] B --> C[Mock] C --> D[Vordefinierte Antwort] D --> B
In Context
- Typically used together with unit tests
- Related to: Stubs, Fakes, Test Doubles
- Example use case: Testing a user interface without database connection