Skip to main content
ActiveJavaTestingTDDTest Doubles

Login Dialog Kata

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.

Objective

Implement tests for a login dialog that depends on an authentication service, manually creating all the necessary types of test doubles.

Rules

  • 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

Types of Test Doubles

  • 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

Technologies

  • Java

  • JUnit 5

  • Maven

Resources

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.

Links

Statistics

Last commit
2024-05-04

Tech Stack

JavaTestingTDDTest Doubles