How To Make Spring Boot Controller Unit Test Faster

Introduction There are several methods for testing Rest controllers in the Spring Boot framework, and this post will demonstrate one of the quickest. Tools Spring Boot: 2.7.6 Java : 11 Rest Controller Let’s create a simple REST API controller with one service to fetch the data from the database. UserController.java @RestController public class UserController { private final UserService userService; public UserController(final UserService userService) { this.userService = userService; } @PostMapping(path = "/user", consumes = MediaType....

January 10, 2023