Juni5 5 supports constructor injection, it would be nice if springs test harness supported it, so you could write spring tests in the same way you write other classes in both junit and spring core. note: I searched this repo and google and didn't find anything.
Comment From: ttddyy
FYI, official document has a section for constructor injection in test with JUnit5.
Comment From: xenoterracide
derp, I are dumb... though I see now what I was really remembering... not wanting to have to put @Autowired
on it, reading that section, is there a reason for needing some decorator? outside of, is it the SpringExtension that's included in all @Spring*Test
decorators that makes spring work?
Comment From: snicoll
@xenoterracide there is really no need to qualify your issue with something in brackets in the description, the team can triage the issue based on title and a description.
This was discussed before, more context in #22924
Comment From: sbrannen
derp, I are dumb... though I see now what I was really remembering... not wanting to have to put
@Autowired
on it, reading that section, is there a reason for needing some decorator?
I'm not sure if you read the entire documentation on the subject, but you do not have to annotate constructors with @Autowired
if you change the global default.
outside of, is it the SpringExtension that's included in all
@Spring*Test
decorators that makes spring work?
If you're talking about test annotations in Spring Boot, then yes. Most if not all of the test related annotations in Spring Boot Test are meta-annotated with @ExtendWith(SpringExtension.class)
so that JUnit Jupiter support for Spring is always enabled.
Comment From: xenoterracide
well, currently I'm using @SpringJUnitWebConfig
and I missed this mentioned documentation because I didn't see any constructor injection being used in this code.
On a related note, if anyone has any ideas about this https://stackoverflow.com/q/65418290/206466. I've tried quite a few things :'( . However this isn't the place for questions, though having read over the docs in spring security on webmvc integration a couple of times I wonder if the docs there couldn't be improved.