Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Support "args" param in "@SpringBootTest" #1447

Closed
wants to merge 1 commit into from

Conversation

ttddyy
Copy link
Contributor

@ttddyy ttddyy commented Jan 13, 2022

Reflectively access SpringBootTestArgs(package private) to support args param in @SpringBootTest.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 13, 2022
Copy link
Contributor

@snicoll snicoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @ttddyy. This is an interesting approach but I'd rather compute the arguments upfront and pass them to the loader instead. This means changing the loader and the source code generator that uses it. We can add a vararg for now so that the code without specific arguments are the same.

@@ -49,6 +55,23 @@
*/
public class AotSpringBootConfigContextLoader extends SpringBootContextLoader {

// "SpringBootTestArgs#get(Set)" static method
private static final Method SPRING_BOOT_TEST_ARGS__GET;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using reflection, I'd rather add an accessor class in spring-native the same way we do elsewhere (a class in the same package that exposes the package-private behavior).

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Jan 13, 2022
@ttddyy
Copy link
Contributor Author

ttddyy commented Jan 14, 2022

Thanks @snicoll, I got a picture.
Yeah, since MergedContextConfiguration is available at aot build time, it should pre-calculate the args. I'll update the change.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jan 14, 2022
Retrieve `args` parameter from `@SpringBootTest` at build time and pass
it to the `AotSpringBootConfigContextLoader` for runtime use.

Signed-off-by: Tadaya Tsuyukubo <tadaya@ttddyy.net>
@sdeleuze
Copy link
Contributor

@snicoll Should we include that in 0.11.2? If yes, can I let you merge it with potential refinement if needed?

@snicoll snicoll added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on status: feedback-provided Feedback has been provided labels Jan 24, 2022
@snicoll snicoll self-assigned this Jan 24, 2022
@snicoll snicoll added this to the 0.11.3 milestone Jan 24, 2022
@snicoll
Copy link
Contributor

snicoll commented Jan 24, 2022

Thanks for the nudge. It looks good but considering we're going to release shortly, I've moved that one to the next release.

snicoll pushed a commit that referenced this pull request Feb 1, 2022
Retrieve `args` parameter from `@SpringBootTest` at build time and pass
it to the `AotSpringBootConfigContextLoader` for runtime use.

See gh-1447
snicoll added a commit that referenced this pull request Feb 1, 2022
@snicoll snicoll closed this in 3c25932 Feb 1, 2022
@snicoll
Copy link
Contributor

snicoll commented Feb 1, 2022

Thanks again @ttddyy

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: enhancement A general enhancement
Development

Successfully merging this pull request may close these issues.

None yet

4 participants