Affects: 5.2.2.RELEASE
When using JUnit Jupiter and the SpringExtension I want to configure it to be able to use constructor injection without putting @Autowired on each parameter. This is supported if I set spring.test.constructor.autowire.mode=all in a file named spring.properties or set matching system property.
However I'm familiar with configuring how junit runs globally among tests by setting properties in the junit-platform.properties file.
Could we add that as an additional lookup for that property to unify this configuration?
Comment From: checketts
FYI @sbrannen
Comment From: sbrannen
Could we add that as an additional lookup for that property to unify this configuration?
That would certainly be possible, and I considered that originally but wasn't sure if people would actually want that as an option.
So, now that you've brought it up, I suppose at least one Spring user would like that feature. 😉
There are two challenges involved.
- The
@TestConstructorsupport is generic by design -- even if it is currently only supported in conjunction with JUnit Jupiter. Thus, we'd have to make the lookup possible without a direct dependency on JUnit Jupiter'sExtensionContextAPI. That can likely be solved via aSupplier<String>argument inTestConstructorUtilsfor an externally sourced properties file lookup. - Which source should take precedence --
spring.propertiesorjunit-platform.properties? I tend to thinkspring.propertiesshould take precedence, only using the externally sourced lookup as a fallback.
Comment From: sbrannen
Current work on this issue can be viewed here: https://github.com/spring-projects/spring-framework/compare/master...sbrannen:issues/gh-24285-test-constructor-junit-config-param