mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-22 14:09:25 +00:00
Prior to this commit, the Bean Override feature in the Spring TestContext Framework (for annotations such as @MockitoBean and @TestBean) silently allowed one bean override to override another "identical" bean override; however, Spring Boot's @MockBean and @SpyBean support preemptively rejects identical overrides and throws an IllegalStateException to signal the configuration error to the user. To align with the behavior of @MockBean and @SpyBean in Spring Boot, and to help developers avoid scenarios that are potentially confusing or difficult to debug, this commit rejects identical bean overrides in the Spring TestContext Framework. Note, however, that it is still possible for a bean override to override a logically equivalent bean override. For example, a @TestBean can override a @MockitoBean, and vice versa. Closes gh-34054