- If you are using Junit version < 5, so you have to use
@RunWith(SpringRunner.class) or @RunWith(MockitoJUnitRunner.class) etc. - If you are using Junit version = 5, so you have to use
@ExtendWith(SpringExtension.class) or @ExtendWith(MockitoExtension.class) etc.
@SpringBootTest
The @SpringBootTest annotation can be used when we need to bootstrap the entire container. The annotation works by creating the ApplicationContext that will be utilized in our tests
@RunWith(SpringRunner.class) && @ExtendWith(SpringExtension.class)
@RunWith(SpringRunner.class) works with Junit4 @ExtendWith(SpringExtension.class) works with Junit5 - You need this annotation to just enable Spring Boot features like
@Autowired ,@MockBean etc… during junit testing
|