How fixing a broken window cut down our build time by 50%
summary
A single central @DirtiesContext on an abstract integration base class forces every test to close its Spring TestContext, causing each new test to start a fresh context and inflating build time from ~25 to ~12 minutes after the fix (a 50% reduction). The fix removes that annotation, replaces inheritance with composition, and standardizes reuse with ApplicationContextInitializer to provision per-context resources (random SQS queues), uses WireMock and Testcontainers for external systems and databases, and favors sliced tests like @WebMvcTest to prevent context explosion.
AI-written summary · about
chapters (19)
- 0:00Intro
- 0:23How Fixing a Broken Window Cut Down Our Build Time by 50%
- 0:37How It Started
- 2:04The Broken Windows Theory
- 2:52It Does Not Always have to Be a Window
- 4:41Impact of Fixing the Broken Window
- 5:55Goals for This Talk
- 7:35Spring TestContext Framework: Context Caching
- 10:21Spring TestContext Framework Context Caching
- 16:31Context Caching and Reusability Red Flags
- 18:13Context Caching Indicators
- 26:30Message Thefts
- 29:47Pitfall #2: Data Overflow
- 32:54Remote Connections
- 41:15Pitfalls: Setup Variety
- 43:03The Result
- 44:29Testing Spring Boot Applications Masterclass
- 45:28Stratospheric - From Zero to Production with Spring Boot and AWS
- 46:28Conclusion
related talks
37mImproving Spring Boot test efficiency
51mTesting Spring Boot Applications
48mCaching the Spring Context in Tests: How to Speed Up Testing
38mScaling Automated Testing & Architecture from Startup to Enterprise
51mAre Your Test Slowing You Down?
46mTesting the untestable - patterns and use cases analysis
54mDirty Tests And How To Clean Them
32mMock my infrastructure! Using Testcontainers for better integration tests.
