Writing Integration Tests Using @SpringBootTest
Understand how to create integration tests in Spring using the @SpringBootTest annotation along with MockMvc. Explore testing strategies that cover controller, service, and repository layers, and verify CRUD operations on REST API endpoints. Gain practical experience running tests with Gradle and ensuring full application configuration is loaded during testing.
We'll cover the following...
The spring Boot testing framework provides the @SpringBootTest annotation that loads the complete application configuration and allows us to use the MockMvc with the @AutoConfigureMockMvc annotation to test through all the layers—controller, service, and repository.
The TodoAppIntegrationTest class
Let’s create the TodoAppIntegrationTest class in the io.educative.integration package. It’s annotated with the @SpringBootTest and @AutoConfigureMockMvc annotations, as well as injected with MockMvc for ...