Kata to practice test doubles by creating a login system with authentication.
A simple and effective kata to practice test doubles. The objective is to test a LoginDialog that has an Authentication dependency without using any mocking library.
Implement tests for a login dialog that depends on an authentication service, manually creating all the necessary types of test doubles.
No mocking libraries: You must create your own test doubles
Practice all types: Dummy, Stub, Spy, Strict Mock and Fake
Understand the differences: Each type of double has a specific purpose
Dummy: Objects that are passed but never actually used
Stub: Provide predefined responses to test calls
Spy: Similar to stubs but record calls for verification
Strict Mock: Pre-programmed with expectations and can throw exceptions
Fake: Functional but simplified implementations
Java
JUnit 5
Maven
The project includes:
Explanatory diagram of the types of doubles
Branch with a Mockito example for comparison
Material used in testing talks
This kata is used in the talk "The Art of War... of Testing: Test Doublers", presented at events like Codemotion Madrid 2024.