You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given the following example test classes, one would expect that Test1 and Test2 would share the same ApplicationContext.
However, due to the current implementation of equals() in OverrideMetadata, the annotations on the logically equivalent messageService fields are compared using Arrays.equals() which takes the declaration order into account. Whereas, the declaration order of the annotations is not relevant for this particular "equality" check.
@SpringJUnitConfig(Config.class)
classTest1 {
@TestBean@Qualifier("system")
MessageServicemessageService;
// rest of test class
}
@SpringJUnitConfig(Config.class)
classTest2 {
@Qualifier("system")
@TestBeanMessageServicemessageService;
// rest of test class
}
In light of the above, we should compare the annotations declared on a Bean Override field using Set semantics.
FYI: Spring Boot's testing support took the same approach in its QualifierDefinition.
The text was updated successfully, but these errors were encountered:
Given the following example test classes, one would expect that
Test1
andTest2
would share the sameApplicationContext
.However, due to the current implementation of
equals()
inOverrideMetadata
, the annotations on the logically equivalentmessageService
fields are compared usingArrays.equals()
which takes the declaration order into account. Whereas, the declaration order of the annotations is not relevant for this particular "equality" check.In light of the above, we should compare the annotations declared on a Bean Override field using
Set
semantics.FYI: Spring Boot's testing support took the same approach in its
QualifierDefinition
.The text was updated successfully, but these errors were encountered: