Mocking a RESTful API
The main drawback of using a remote service as we did in the previous recipes is that you need the remote service running when you test your client application. To tackle this scenario, you can mock a remote server. By mock, I mean simulating the behavior of a component or service, in this case, the remote service.
Mocking a remote dependency in a test can be useful for several reasons. One of the main reasons is that it allows you to test your code in isolation, without having to worry about the behavior of the remote dependency. This can be especially useful if the remote dependency is unreliable or slow, or if you want to test your code in different scenarios that are difficult to reproduce with the remote dependency.
In this recipe, we’ll learn how to use Wiremock to mock the remote Football
service in our Albums application during the testing execution.
Getting ready
In this recipe, we’ll create the tests for the application we built...