Asserting Word Selection and Refactoring Using Mock Setup

Improve the accuracy of the Wordz game by asserting and refining word selection for seamless gameplay.

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 can reuse our getGameInRepository() assert helper method:

Get hands-on with 1400+ tech skills courses.