Closed
Description
As a follow up of #22286, this ticket is supposed to discuss the idea of a canonical annotation to be used with test classes that constitute Spring integration tests and configure JUnit to treat the class like a Spring component as much as possible. In detail, this includes:
- The instances of the test class are singletons by default
- Dependency injection (esp. constructor injection) works just as for Spring components
This could effectively look something like this (name TBD):
@SpringJUnitConfig // Bootstrap Spring container
@AutowireTestConstructor // Enable constructor injection
@TestInstance(Lifecycle.PER_CLASS) // Singleton, i.e. one instance for all test method invocations
// other annotations needed
@interface SpringTest { // SpringTest as that's in line with @SpringBootTest
// add aliases for attributes of above annotations
}
The goal is to minimalize the conceptual differences between a Spring component in production code and a integration test class.