Simulierte Abhängigkeiten in Tests
Beim Unit-Test wollen Sie häufig einen Teil eines vollständigen Systems isoliert betrachten, d. h. ohne Abhängigkeiten berücksichtigen zu müssen. Zum Testen eines Systemteils können wir die Abhängigkeiten mithilfe von Mock-Objekten ersetzen. Ein Mock-Objekt dient der Umsetzung von mindestens einem Teil einer Schnittstelle des Produktionsobjekts, jedoch häufig auf einfachere, schnellere, besser vorhersehbare bzw. besser steuerbare Weise.
Informationen zum Einstieg finden Sie unter Create Mock Object.
Klassen
Themen
- Create Mock Object
Test a portion of a complete system in isolation using a mock.
- Specify Mock Object Behavior
Define behavior for mocked methods and properties. For example, you can specify that a method returns predefined values.
- Qualify Mock Object Interaction
Intercept messages sent from the component under test to the mock object. For example, you can verify that a method was called or a property was set.
- Write Tests That Use App Testing and Mocking Frameworks
Create fully automated tests for an app by using the app testing framework and the mocking framework.