Skip to content
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

@DynamicPropertySource in @Nested test class cannot override dynamic properties from enclosing class #31083

Closed
wants to merge 1 commit into from

Conversation

quaff
Copy link
Contributor

@quaff quaff commented Aug 21, 2023

@sbrannen
Copy link
Member

@sbrannen sbrannen changed the title Allow overriding dynamic property from enclosing class in inner class Allow overriding dynamic property from enclosing class in @Nested test class Aug 21, 2023
@sbrannen sbrannen added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 21, 2023
@sbrannen sbrannen added this to the 6.0.12 milestone Aug 21, 2023
@sbrannen sbrannen changed the title Allow overriding dynamic property from enclosing class in @Nested test class @DynamicPropertySource in @Nested cannot override dynamic properties from enclosing class Aug 21, 2023
@sbrannen sbrannen changed the title @DynamicPropertySource in @Nested cannot override dynamic properties from enclosing class @DynamicPropertySource in @Nested test class cannot override dynamic properties from enclosing class Aug 21, 2023
@sbrannen sbrannen closed this in 368036c Aug 21, 2023
@sbrannen sbrannen added the status: backported An issue that has been backported to maintenance branches label Aug 21, 2023
sbrannen pushed a commit that referenced this pull request Aug 21, 2023
… class

Prior to this commit, a dynamic property registered via a
@DynamicPropertySource method in a @nested test class was not able to
override a property registered via a @DynamicPropertySource method in
the enclosing class.

See gh-26091
Closes gh-31083
sbrannen added a commit that referenced this pull request Aug 21, 2023
@sbrannen
Copy link
Member

This has been merged into 6.0.x and main in 368036c and revised in 620a87b.

This has also been backported to 5.3.x (see #31085).

Thanks for noticing the issue in the Spring Boot issue tracker, fixing it, and submitting the PR! 👍


Side note: after attempting to backport this to 5.3.x, I realized why I had never tested it in the first place. Static members in inner classes were not supported in Java until Java 16 with the introduction of records (see https://bugs.openjdk.org/browse/JDK-8254321), and we didn't start authoring tests in Java 17 until 6.0. Thus, I had to remove the DynamicPropertySourceOverridesEnclosingClassTests class on the 5.3.x branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@Nested classes with nested @DynamicPropertySource get called in order, but don't get applied
3 participants