Testing Spring Cloud Gateway
As the Spring Cloud Gateway rules are processed at runtime, they can sometimes be difficult to test. In addition to the rules themselves, the target applications must be up and running.
In this recipe, we’ll learn how to test Spring Cloud Gateway using the Spring Cloud Contract Stub Runner starter, which emulates the target services using the Wiremock library.
Getting ready
In this recipe, we’ll create tests for the Spring Cloud Gateway project we set up in the previous recipe. I’ve prepared a working version of Spring Cloud Gateway in case you haven’t set it up yet. You can find it in this book’s GitHub repository at https://github.com/PacktPublishing/Spring-Boot-3.0-Cookbook. The code to start this recipe can be found in the chapter4/recipe4-5/start
folder. I’ve added all the projects that were used in the previous recipe – that is, the football
, the albums
, and the gateway
projects – but...