Search⌘ K
AI Features

Handling Multiple Guesses in the Wordz Gameplay

Explore the process of test-driving the Wordz game endpoint that accepts multiple guess attempts. Understand how to create integration tests for a POST /guess route, handle JSON request and response formats, and verify game-over conditions. This lesson shows how to link web requests to domain logic, apply test doubles, and design APIs effectively.

In this lesson, we’ll test-drive the code to play the game. This involves submitting multiple guess attempts to the endpoint until a game-over response is received.

Submitting multiple guesses

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 for class Wordz to assess the score for a guess, along with reporting whether the game is over. To test-drive this, we set up the mockWordz stub to return a valid GuessResult object when the ...