Search⌘ K

Asserting Word Selection and Refactoring Using Mock Setup

Explore asserting word selection in a game using mock setups with Mockito to ensure proper data flow in Test-Driven Development. Learn to write assertions, handle failing tests with mocks, and refactor tests to improve readability, maintaining reliable and clear domain logic.

In the previous lesson, we sharpened Wordz game creation by triangulating word selection, guaranteeing randomness. We set up mocks for the word repository and random number generator, refining test clarity. This lesson focuses on asserting word selection in Wordz, ensuring its proper passage to the create() method of gameRepository through TDD and Mockito for mock setup.

Asserting word selection

  • Now, we can write the assertion to confirm that this word is passed down to the gameRepository create() method. We ...