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.
We'll cover the following...
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 classWordzto 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 the ...