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

Change @TestConstructor.autowire attribute into an enum #23224

Closed
philwebb opened this issue Jul 1, 2019 · 5 comments
Closed

Change @TestConstructor.autowire attribute into an enum #23224

philwebb opened this issue Jul 1, 2019 · 5 comments
Assignees
Labels
in: test Issues in the test module type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

philwebb commented Jul 1, 2019

I think it's possible that we might want to support different autowire modes with @TestConstructor in the future. Specifically, I think it would be nice if we could mix autowire with other extension mechanisms and have autowiring apply only when no other ParameterResolvers match.

I wonder if we should change autowire from a boolean to an enum so we can add more options in the future.

e.g.:

@TestConstructor(autowire=Autowire.ANNOTATED)
@TestConstructor(autowire=Autowire.ALL)
@TestConstructor(autowire=Autowire.REMAINING)
@philwebb
Copy link
Member Author

philwebb commented Jul 1, 2019

Whoops, I raised this in the wrong repo. Transferred to spring-framework.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 1, 2019
@sbrannen sbrannen added in: test Issues in the test module type: enhancement A general enhancement labels Jul 3, 2019
@sbrannen sbrannen self-assigned this Jul 3, 2019
@sbrannen
Copy link
Member

sbrannen commented Jul 3, 2019

Thanks for raising the issue, @philwebb.

I agree that having an enum would allow for greater flexibility in the future. So, with that in mind, I'll likely make the change before 5.2 is released.

Regarding the proposed enum constants, allow me to make that a little bit more concrete.

  • Autowire.ANNOTATED: only autowires if the individual parameter is annotated with @Autowired, @Qualifier, or @Value
  • Autowire.ALL: autowires all parameters as if the constructor were annotated with @Autowired
  • Autowire.REMAINING: ???

Is that what you had in mind, and what are the intended semantics for REMAINING?

I'm guessing you mean all remaining parameters that have not been claimed to be supported by other registered parameter resolvers.

have autowiring apply only when no other ParameterResolvers match.

Regarding that point, I agree that that would be nice. Unfortunately, there is currently no way to achieve that with the available extension APIs in JUnit Jupiter. Though, perhaps a future release of JUnit Jupiter will provide such support, in which case an enum would allow us to support that autowire mode as well.

Speaking of that, would you like to open an issue in the JUnit 5 GitHub repository requesting functionality along those lines? (if not, I can do that for you)

@sbrannen sbrannen added this to the 5.2 RC1 milestone Jul 3, 2019
@philwebb
Copy link
Member Author

philwebb commented Jul 3, 2019

I'm guessing you mean all remaining parameters that have not been claimed to be supported by other registered parameter resolvers.

Exactly. I just wanted to add it so we could consider the name in the context of the others.

Speaking of that, would you like to open an issue in the JUnit 5 GitHub repository requesting functionality along those lines?

I've raised junit-team/junit5#1945

@sbrannen sbrannen removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Jul 7, 2019
@sbrannen sbrannen changed the title Change TestConstructor.autowire parameter into an enum Change @TestConstructor.autowire attribute into an enum Jul 7, 2019
@sbrannen
Copy link
Member

@philwebb, what do you think of the changes in fc38bb4?

@philwebb
Copy link
Member Author

@sbrannen LGTM 👍

sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jul 12, 2019
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 type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants