-
Notifications
You must be signed in to change notification settings - Fork 38.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@TestBean
and @MockitoBean
tests fail in AOT mode
#32925
Comments
@TestBean
"by type" tests fail in AOT mode@TestBean
"by type" tests and @MockitoBean
tests fail in AOT mode
As a follow up to the previous commit (31f8e12), this commit polishes bean override tests and revises them with a focus on AOT testing support and simplified maintenance. - Introduce EngineTestKitUtils to simplify working with JUnit's EngineTestKit. - Use idiomatic EngineTestKit APIs to simplify assertions on EngineTestKit results. - Introduce BeanOverrideTestSuite to simplify running all bean override tests within the IDE. - Separate failure and success scenario tests, so that failure tests do not launch the JUnit Platform to run tests using the Spring TestContext Framework (TCF) within a test class that itself uses the TCF. - Make AbstractTestBeanIntegrationTestCase actually abstract. - Rename test case classes to give them meaningful names and simplify understanding of what's being tested. - Ensure tests for @MockitoSpyBean functionality use @MockitoSpyBean instead of @MockitoBean. - Declare @Configuration classes local to @SpringJUnitConfig test classes whenever possible. See gh-29122 See gh-32925
@TestBean
"by type" tests and @MockitoBean
tests fail in AOT mode@TestBean
and @MockitoBean
tests fail in AOT mode
Quoting #32933:
That is partially accurate. The mockito support in Spring Boot never worked in AOT mode on the JVM. It current fails as follows:
That is because the TCF requires the key for a context to be computed at a certain time and makes it very AOT unfriendly as a result. I think this issue needs to be requalified as we need to fix that. Next up, the support works by registering a singleton with a "dummy" bean definition and that's why this is failing. |
This issue is no longer relevant as it's obvious that bean overriding does not work with AOT. And we already have an issue to investigate how to fix that, see #32933 |
Overview
When running various bean override tests in AOT mode (via
AotIntegrationTests
), AOT processing fails with a stack trace similar to the following.The key part is this:
... which seems like a relatively empty
BeanDefinition
.Failing Test Classes
TestBeanByTypeIntegrationTests
TestBeanInheritanceIntegrationTests$ConcreteTestBeanIntegrationTests
MockitoBeanByTypeIntegrationTests
MockitoBeanIntegrationTests
Related Issues
spring-test
module #29122The text was updated successfully, but these errors were encountered: