Spring Testing

Spring Boot @DataJpaTest

Spring boot @DataJpaTest annotation focuses on JPA components and apply configuration only relevant to JPA tests. It helps in testing @Repository classes.

Spring Boot @MockBean Example

Spring boot @MockBean annotation used to add mocks to a Spring ApplicationContext. In this tutorial, we will learn the different ways to use this annotation.

Integration Testing with @SpringBootTest and JUnit 5

The @SpringBootTest annotation in Spring Boot allows us to create integration tests by loading the entire application context. It acts as a bridge between the application configuration and the test framework so that tests can verify the behavior of your application in an environment similar to production.

Spring Boot 3 with JUnit 5

Learn to include JUnit 5 in a Spring boot application and write unit tests. Check out a demo of JUnit 5 tests for Spring Boot REST controller.

Spring Boot MockMvc Example with @WebMvcTest and MockitoBean

Test Spring Boot REST controllers with MockMvc and @WebMvcTest. Replace the service with a @MockitoBean mock and send GET, POST, PUT and DELETE requests with JSON. Then check status codes, validation errors and @RestControllerAdvice responses. Also covers MockMvcTester (AssertJ) and real andDo(print()) output on Spring Boot 4.1.1.

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.