Curse of Spring Boot Test
summary
Shows that using Spring Boot test annotations often does more than expected: SpringBootTest loads entire application context and that makes tests slow and unpredictable; the context cache is fragile and gets invalidated by different annotation combinations, profiles or property orders. Demonstrates fixes used in live code: narrow @SpringBootTest with explicit configuration, add a @TestConfiguration stop to prevent upward scanning, prefer DataJpaTest/WebMvcTest for slices, and use context hierarchies to reuse one cached context; also warns about duplicate beans caused by naming mismatches.
AI-written summary · about
chapters (23)
- 0:00Introduction
- 1:51Test types overview
- 3:21Demo setup
- 5:32Unit test basics
- 8:51Component test introduction
- 10:15Spring context configuration
- 12:06Testing expert resolvers
- 13:10Handling multiple experts
- 17:51Spring Boot Test setup
- 18:12Context caching concerns
- 24:25Context hierarchy benefits
- 28:42Cache invalidation issues
- 31:03Spring vs Spring Boot Test
- 33:23Cache validation demo
- 36:53Cache reset techniques
- 37:15Testing cache service
- 41:07Bean naming conflicts
- 42:54Spring Boot Test scanning
- 46:28Fixing scanning issues
- 47:50Stop configuration solution
- 48:13Data JPA and Web MVC tests
- 50:45Mocking in tests
- 53:17Summary and best practices
