You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
VScode quick fix should not suggest removing @Autowired annotation from JUnit tests #786
After a recent update of Spring Boot extension for VSCode, it starts to suggest removing @Autowired annotation from JUnit tests
However, after the annotation is removed, test is unable to get launched:
org.junit.jupiter.api.extension.ParameterResolutionException: No ParameterResolver registered for parameter [org.springframework.test.web.servlet.MockMvc mvc] in constructor [public com.newpathfly.flightsupplier.via.service.SearchServiceIT(org.springframework.test.web.servlet.MockMvc,java.lang.String)].
at java.util.Optional.orElseGet([Optional.java:267](vscode-file://vscode-app/c:/Users/xiaoh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html))
at java.util.ArrayList.forEach([ArrayList.java:1259](vscode-file://vscode-app/c:/Users/xiaoh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html))
at java.util.ArrayList.forEach([ArrayList.java:1259](vscode-file://vscode-app/c:/Users/xiaoh/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-browser/workbench/workbench.html))
To Reproduce
Build a simple Spring Boot test in an existing Spring Boot project:
Don't think i have better ideas than skipping the case of a class with @SpringBootTest annotation. Any objections?
What's the root cause of the issue?
Would you be able to skip the case of a class with any annotation that @BootstrapWith(SpringBootTestContextBootstrapper.class) in case people have their own annotation versus @SprintBootTest?
Activity
BoykoAlex commentedon Jun 15, 2022
Yes, agreed. Will get this fixed
BoykoAlex commentedon Jun 16, 2022
Don't think i have better ideas than skipping the case of a class with
@SpringBootTestannotation. Any objections?tigerinus commentedon Jun 16, 2022
What's the root cause of the issue?
Would you be able to skip the case of a class with any annotation that
@BootstrapWith(SpringBootTestContextBootstrapper.class)in case people have their own annotation versus@SprintBootTest?BoykoAlex commentedon Jun 16, 2022
We've added removing @Autowired from the only constructor in class but conditions for this marker and quick fix are buggy.
Yes we can skip class annotated with
@BootstrapWith(SpringBootTestContextBootstrapper.class)as well without any problems. Thanks for bringing this upBoykoAlex commentedon Jun 16, 2022
The fix is 382d0bb.
We'll be creating another release in a few days from now to include this fix. Once the RC is tested I'll mark it as fixed.
BoykoAlex commentedon Jun 17, 2022
@tigerinus here is the RC that I've tried: https://s3.us-west-1.amazonaws.com/s3-test.spring.io/sts4/vscode-extensions/snapshots/vscode-spring-boot-1.36.0-RC.1.vsix
Seemed to work fine there.