We have learned how easy it is to create microservices using Spring Framework, but now we need to learn how we can test them, and how Spring can help us. First, we will create a small microservice that will later be used for testing. Then, we will understand what is SpringBootTest and how we can test our beans using JUnit. Finally, we will learn how we can test our controller using MockMvc.
Understanding SpringBootTest
Creating a simple microservice
In order to create our microservice, we will use Spring Initializr, as we have been doing in the previous chapters.
We can start by visiting https://start.spring.io/:
Spring Initializr
We have chosen to create a Maven Project using Kotlin and Spring Boot 2.0.0 M7. We choose Group...