Sitemap
Makara SENG

Makara SENG

Software Engineer sharing practical lessons on backend development, Spring Boot, system design, DevOps, and real-world engineering.

Member-only story

Stop Using @SpringBootTest for Everything: A Faster Test Strategy

20 min readOct 26, 2026
Press enter or click to view image in full size

In many Spring Boot code bases, every test starts the same way: @SpringBootTest at the top of the class. It is the annotation the project generator puts in the first test, it always works, and it never makes you think about which beans a test needs. Then the suite grows to a few hundred classes, a full build takes ten minutes, and nobody runs the tests before pushing anymore.

The usual advice is to replace most of those tests with unit tests and test slices. That advice is mostly right, but the reason it is right is often misstated. A @SpringBootTest is not slow because it is big. Spring caches application contexts between test classes, so one big context costs you once. It becomes slow when every test class asks for a slightly different big context, and when a developer runs one test and has to wait for the whole application to start.

This article puts numbers on that. It builds one small Spring Boot 4.1.1 application, tests the same behaviour three ways, measures each way, and then breaks the application on purpose seven times to see which tests notice. The goal is a strategy you can defend with data: what to test without Spring, what to test with a slice, what still needs the whole application, and how to keep the expensive part cheap.

--

--

Makara SENG
Makara SENG

Written by Makara SENG

Software Engineer sharing practical lessons on backend development, Spring Boot, system design, DevOps, and real-world engineering.