Spring provides a modular Java application model built around declarative configuration, dependency injection, and infrastructure abstractions. Its ApplicationContext discovers, creates, and exposes application components as beans, avoiding imperative wiring between classes. section 1.3 section 1.0
Spring Boot applies Spring conventions to reduce configuration, especially for testing:
- Detects dependencies such as spring-boot-starter-webmvc and starts a web server on port 8080. section 1.0
- Creates and connects testing utilities such as MockMvcTester to the application context. section 1.0
- Provides familiar annotations such as @Autowired and @TestConfiguration for test-specific component wiring. section 1.0
- Trades manual control for convenience; broad Spring contexts can add configuration complexity and affect test-suite speed. section 1.3 section 1.0
Replacing an external dependency in a test application
A test configuration can scan the application while excluding the production WidgetValidator, load test.properties, and register a StubWidgetValidator bean instead. Tests can then exercise the remaining application components without running the external service. section 1.3
Figure 1.3 The architecture of the application we would like to test. Arrows represent the data flowing through the system. The WidgetValidator cannot be used in tests, and needs to be replaced by a stub.
Use the architecture diagram to trace the controller, repository, and external validator, then identify the dependency that tests replace with a stub. section 1.3




