Categories
java junit mockito spring-boot unit-testing

How to test a component / bean in Spring Boot

To test a component/bean in a Spring Boot application, the testing part of the Spring Boot documentation provides much information and multiple ways :
@Test, @SpringBootTest, @WebMvcTest, @DataJpaTest and still many other ways.

Why provide so many ways ?
How decide the way to favor ?

Should I consider as integration tests my test classes annotated with Spring Boot test annotations such as @SpringBootTest, @WebMvcTest, @DataJpaTest ?

PS : I created this question because I noticed that many developers (even experienced) don’t get the consequences to use an annotation rather than another.