The context can be reused between tests. If you're not storing data in beans (which you normally shouldn't), this works well. There is a bit of subtlety in that the framework might have to create multiple context for different configurations, but each of them is reusable.
Running a single test is a bit of pain, but running the whole suite is not a lot slower than if it didn't use Spring.
Re:Spring vs. Java EE
by jacques_chester on Sunday April 09, 2017 @08:52PM
(#14075221)
If you're firm on constructor injection, you can typically test the object in complete isolation without necessarily using mocks, without Spring having to be involved.
Or you can use mocks and Spring Boot's test annotations.
But with field/setter injection, that choice isn't as easy.
How do you handle the Spring context start-up time? In Spring projects I've worked on, across hundreds of unit tests it's non-trivial. But I don't make any claim to know if we were doing Spring right or not.