Spring Boot – Rest Controller Unit Test with @WebMvcTest

Nowadays Unit Test is so important in Software Development, and Spring Boot Test also provides @WebMvcTest annotation to make writing unit test for Rest Controller more simpler. In this tutorial, we’re gonna look at how to apply @WebMvcTest in our Spring Boot Project with JUnit 5 and Mockito.

More Practice:
@DataJpaTest example in Spring Boot
@RestControllerAdvice example in Spring Boot
Spring Boot Token based Authentication with Spring Security example

Associations:
Spring Boot One To One example with JPA, Hibernate
Spring Boot One To Many example with JPA, Hibernate
Spring Boot Many to Many example with JPA, Hibernate

Read More

@RestControllerAdvice example in Spring Boot

In this tutorial, we’re gonna look at an Spring Boot example that uses @RestControllerAdvice for exception handling in Restful API. I also show you the comparison between @RestControllerAdvice and @ControllerAdvice along with the use of @ExceptionHandler annotation.

Related Posts:
Spring Boot, Spring Data JPA – Rest CRUD API example
Spring Boot Pagination & Filter example
Spring Boot Sort/Order by multiple Columns

More Practice:
Spring Boot Multipart File upload example
Spring Boot Token based Authentication with Spring Security & JWT

Unit Test:
Spring Boot Unit Test for JPA Repositiory
Spring Boot Unit Test for Rest Controller

Read More