To enable testing, the following dependency in the pom.xml file is used:


To test the RestaurantController, the following files have been added:

  • The RestaurantControllerIntegrationTests class uses the @SpringBootTest annotation to pick the same configuration that Spring Boot uses. Also, we use the SpringRunner class to run our integration tests. Please find the restaurant API integration test code:
@RunWith(SpringRunner.class)@SpringBootTest(classes = RestaurantApp.class, webEnvironment = WebEnvironment.RANDOM_PORT, properties = {    "management.server.port=0", "management.context-path=/admin"})public class RestaurantControllerIntegrationTests ...

Get Mastering Microservices with Java - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.