Junior — Middle
How many Spring Boot contexts will be created when using the @SpringBootTest annotation for two classes?
sobes.tech AI
Answer from AI
When using the @SpringBootTest annotation for two different classes, by default, two separate Spring contexts will be created, one for each class.
This is because each test class runs in its own context to ensure isolation and independence of tests.
If you need to use a common context for multiple tests, you can apply the @DirtiesContext annotation or configure context caching, but by default — two classes = two contexts.