Playing the game
In this section, we will test-drive the code to play the game. This involves submitting multiple guess attempts to the endpoint until a game-over response is received.
We start by creating an integration test for the new /guess route in our endpoint:
- The first step is to code the Arrange step. Our domain model provides the
assess()method onclass Wordzto assess the score for a guess, along with reporting whether the game is over. To test-drive this, we set up themockWordzstub to return a validGuessResultobject when theassess()method is called:@Test
void partiallyCorrectGuess() {var score = new Score("-U---");score.assess("GUESS");var result = new GuessResult(score, false, false);
when(mockWordz.assess(eq(player), eq("GUESS"))).thenReturn(result);
}
- The...