spring-native
spring-native copied to clipboard
Reintroduce support for Spring Boot's ConditionEvaluationReport in AOT and native tests
Overview
As discussed in https://github.com/spring-projects-experimental/spring-native/issues/1169#issuecomment-967002442, SpringBootDependencyInjectionTestExecutionListener
is no longer used in AOT and native tests. Consequently, Spring Boot's ConditionEvaluationReport
support has been lost for Spring integration tests.
Analysis
AotDependencyInjectionTestExecutionListener
is currently generic in the sense that it is not based on Spring Boot's testing support. This means it could be used in the future with standard Spring integration tests that don't rely on Spring Boot testing features.
We could effectively copy-n-paste code from SpringBootDependencyInjectionTestExecutionListener
to AotDependencyInjectionTestExecutionListener
to reintroduce support for ConditionEvaluationReport
.
Alternatively, we could introduce a variant of AotDependencyInjectionTestExecutionListener
that is specific to Spring Boot and contains the ConditionEvaluationReport
support.
Deliverables
- [ ] Decide if we wish to reintroduce support for
ConditionEvaluationReport
inAotDependencyInjectionTestExecutionListener
.
I raised this issue to make us all aware of the fact that ConditionEvaluationReport
support has been lost for Spring integration tests.
However, I do not see this as a high priority issue.
We can address this at a later date.
This isn't test specific, the evaluation report for the main app is also gone and should be reintroduced in some form.
Probably worth noting that SpringBootDependencyInjectionTestExecutionListener
only outputs the report upon refresh failure and that, currently, it doesn't work as intended.
Probably worth noting that
SpringBootDependencyInjectionTestExecutionListener
only outputs the report upon refresh failure and that, currently, it doesn't work as intended.
Ahhhh.... that's good to know. Thanks for sharing. I subscribed to the Boot issue.
@sbrannen @snicoll I am hitting some issues with @DynamicPropertiesSource only when I run with AOT enabled mode and TestContainers.. but my gut tells me that this is just AOT stuff not working. I am using Spring Boot 2.7.0 with Spring Native 0.12.0, but I've tried older versions too:
If I comment AOT for tests everything works ok https://github.com/salaboy/fmtok8s-agenda-service/blob/main/pom.xml#L211
If AOT is enabled for tests then the @DynamicPropertySource doesn't work here: https://github.com/salaboy/fmtok8s-agenda-service/blob/main/src/test/java/com/salaboy/conferences/agenda/controller/AgendaServiceApplicationTest.java#L67
This makes me wonder.. why do we need AOT for tests? The configuration from my project is based on what is generated in http://start.spring.io when you add Spring-Native to the mix.
@salaboy I don't understand how this issue is related to what you're reporting.
why do we need AOT for tests?
To run them in a native image. If you don't need that you can remove that goal. We can't really help you with the info that you've shared but I suppose @DynamicPropertySource
isn't supported by AOT at the moment.
@snicoll I guess that I was trying to verify this:
To run them in a native image. If you don't need that you can remove that goal. We can't really help you with the info that you've shared but I suppose @DynamicPropertySource isn't supported by AOT at the moment.
Do we have any validation about that?
The commented section in the pom.xml
file is provided by default on start.spring.io so I wonder why do we need that in the first place? Why is that the default configuration for the AOT plugin?
Sorry.. so I guess the real issue that I am reporting is that @DynamicPropertySource
is not supported with AOT.. but because I wasn't sure of that I started doubting the AOT plugin default configurations. I will need to check, but I believe that for Gradle might have different defaults.
Why is that the default configuration for the AOT plugin?
To maximize feedback from the community.
I guess the real issue that I am reporting is that @DynamicPropertySource is not supported with AOT
That shouldn't be reported in this issue. We'll take that into consideration in Spring Boot 3.
Spring Native is now superseded by Spring Boot 3 official native support, see the related reference documentation for more details.
As a consequence, I am closing this issue, and recommend trying your use case with latest Spring Boot 3 version. If you still experience the issue reported here, please open an issue directly on the related Spring project (Spring Framework, Data, Security, Boot, Cloud, etc.) with a reproducer.
Thanks for your contribution on the experimental Spring Native project, we hope you will enjoy the official native support introduced by Spring Boot 3.