Description
Overview
Although @MockitoBean
and @MockitoSpyBean
will not work out-of-the-box within a GraalVM native image due to their dependency on Mockito, the general Bean Override support for tests should ideally work within a native image.
In light of that, we need to ensure that basic usage of @TestBean
is supported within a native image, and (if applicable) we will need to document known use cases that are not supported for some reason.
To achieve that, we need to introduce a smoke test application that makes use of @TestBean
and verify the expected behavior when the associated tests are run within a native image against Spring Framework 6.2 snapshots or milestones.
We also have to ensure that the necessary runtime hints are registered for the bean override support. For example, we will need tests which verify that reflection hints are registered for the BeanOverrideContextCustomizerFactory
, etc.
As a bare minimum, TestContextAotGeneratorIntegrationTests.endToEndTests()
must be modified to include test classes that utilize the basic features of @TestBean
.
Related Issues
- Help wanted: compiling mockito with native-image mockito/mockito#2435
- Support Mockito with @MockBean and @SpyBean in AOT-processed tests spring-boot#32195
- Verify AOT testing support for all tests in the
spring-test
module #29122 @TestBean
and@MockitoBean
tests fail in AOT mode #32925- Introduce dedicated AOT tests for bean override support in the TCF #32932