An integration test checks that independently developed units work together. In a Spring Boot application, it also checks their integration with Spring capabilities such as the web or data layer. It may include a database, but need not exercise every external dependency. Its scope sits between a focused unit test and a full end-to-end test. section 1.2
Spring Boot Test reduces the setup needed for this scope: it starts the application for tests, makes beans available through @Autowired, and cleans up afterward. With @SpringBootTest, it finds and runs the application's @SpringBootApplication class. Tests can exercise HTTP endpoints with MockMvcTester, inspect results or application state, and replace beans to stub external services. section 1.6 section 2.8
Listing 2.1 The test bundled in a Spring Initialzr-based project.
@SpringBootTest #1
class WeatherApplicationTests {
@Test #2
void contextLoads() { #2
}
}
The generated @SpringBootTest class is a useful starting point, not a feature test: its empty contextLoads method establishes only that the application starts. Add actions and assertions to check application behavior. section 2.2 section 2.0
Choose the scope deliberately. A startup check can expose missing beans or invalid properties, but it cannot verify business logic. Integration tests suit user scenarios that exercise cooperating parts of an application. For complex logic with many input variations, prefer focused unit tests over repeatedly starting the full application and arranging extensive test state. section 2.2 section 2.7







































