Integration Tests with @SpringBootTest
Test the whole application context.
What is an Integration Test
An integration test exercises multiple layers together — controller, service, repository — using a real Spring context.
It catches wiring and configuration problems that unit tests miss.
@SpringBootTest
@SpringBootTest boots the entire application context, loading all beans.
@SpringBootTest
class ApplicationIntegrationTest {
@Autowired
UserService userService;
@Test
void contextLoads() {
assertThat(userService).isNotNull();
}
}All lessons in this course
- Unit Testing with JUnit and Mockito
- Web Layer Tests with MockMvc
- Integration Tests with @SpringBootTest
- Real Dependencies with Testcontainers