In Spring Boot + JUnit5 environment, NullPointerException occurs because @Autowired does not work in the test class and the instance is not created in the variable.
In JUnit5, it turned out that the setting to run Spring Boot is different from JUnit4.
migrate from JUnit 4 to JUnit 5 you can replace
@RunWith(SpringRunner.class) with @ExtendWith(SpringExtension.class).
It took me quite a while to get to the reference page.
https://stackoverflow.com/questions/48019430/junit5-with-spring-boot-1-5
Recommended Posts