I was using @SpringBootTest
annotation to run integration tests. but it suddenly stopped working! it does not load the context anymore, it just runs as a unit test and all injected beans are null. I do not remember what change I made. so, what can cause this problem?
the Spring Boot version is 2.3.
The context is loaded by adding
@RunWith(SpringRunner.class)
.
CodePudding user response:
I think you don't need to specify @RunWith(SpringRunner.class)
as @SpringBootTest
itself contains @ExtendWith(SpringExtension.class)
.
Also make sure that you still have Application class with public static void main(String[] args)
annotated with @SpringBootApplication
under /main/java/
directory in the same module.
CodePudding user response:
the problem was solved. the @Test
annotation was not the correct one! It should be org.junit.jupiter.api.Test
. stupid IDE auto import!