This is not a bug: this is by design.
The reason this does not work is that this form of configuration is simply not supported by Spring.
The algorithm that the Spring Framework uses when searching for an annotation stops once it has found the first occurrence of the sought annotation. Thus, in your example, the @ActiveProfiles
annotation on NotWorkingTest
effectively shadows the @ActiveProfiles
annotation on your composed @EmbeddedMongoDBUnitTest
annotation.
Please note that these are the general semantics for annotations in the core Spring Framework. In other words, the behavior you are experiencing is not specific to the spring-test
module.
Having said that, profiles declared via @ActiveProfiles
are in fact inherited within a test class hierarchy (unless you set the inheritProfiles
flag to false
). But don't confuse class hierarchies with annotation hierarchies: Java supports inheritance for interfaces and classes but not for annotations.
Hope this clarifies things!
Sam (component lead for the spring-test
module)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…