Skip to content

Document that @ConfigurationProperties beans are not scanned in sliced tests #23210

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

Closed
MrBuddyCasino opened this issue Sep 7, 2020 · 3 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@MrBuddyCasino
Copy link

Affects: 2.2.4.RELEASE

The @ConfigurationPropertiesScan annotation does not work in a @WebFluxTest and fails to pick up any classes. Referencing classes explicitly via @EnableConfigurationProperties works but shouldn't be required. The project uses Kotlin 1.4.

Here is a minimal test case to reproduce the issue:
https://github.com/MrBuddyCasino/spring-boot-property-binding-bug

@bclozel bclozel transferred this issue from spring-projects/spring-framework Sep 7, 2020
@bclozel bclozel added the status: waiting-for-triage An issue we've not yet triaged label Sep 7, 2020
@wilkinsona wilkinsona changed the title [Bug] @ConfigurationPropertiesScan not working in @WebFluxTest @ConfigurationPropertiesScan not working in @WebFluxTest Sep 7, 2020
@wilkinsona wilkinsona changed the title @ConfigurationPropertiesScan not working in @WebFluxTest @ConfigurationPropertiesScan does not work with sliced tests Sep 7, 2020
@wilkinsona
Copy link
Member

Thanks for the sample.

@WebFluxTest filters the beans that are registered by scanning and this filtering excludes @ConfigurationProperties-annotated beans. This behaviour isn't specific to @WebFluxTest as none (IIRC) of the sliced @…Test annotations include @ConfigurationProperties beans.

I'm flagging this for team attention so that we can discuss what, if anything, we want to do here. It may be that we decide to change the behaviour or perhaps just make and update to the documentation to clarify the current behaviour.

@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Sep 7, 2020
@MrBuddyCasino
Copy link
Author

Thanks for the quick feedback. In the meantime, I guess @EnableConfigurationProperties is the best workaround for now?

@snicoll
Copy link
Member

snicoll commented Sep 8, 2020

I don't think it is a workaround but what you should be doing the same way you should use @Import if you want to add an additional component. The current behaviour is what we expect to happen, see this comment and #16659.

As for the documentation it currently states the following:

@WebFluxTest auto-configures the Spring WebFlux infrastructure and limits scanned beans to @Controller, @ControllerAdvice, @JsonComponent, Converter, GenericConverter, WebFilter, and WebFluxConfigurer.

@philwebb philwebb added type: documentation A documentation update and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Sep 9, 2020
@philwebb philwebb added this to the 2.2.x milestone Sep 9, 2020
@wilkinsona wilkinsona self-assigned this Sep 10, 2020
@wilkinsona wilkinsona changed the title @ConfigurationPropertiesScan does not work with sliced tests Document that @ConfigurationProperties beans are not scanned in sliced tests Sep 10, 2020
@wilkinsona wilkinsona modified the milestones: 2.2.x, 2.2.10 Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

5 participants