I use Project Lombok for my Java projects.
My Controller looks like this:
@RestController
@AllArgsConstructor
public class UserController {
private RegisterService registerService;
private UserService userService;
private UserValidator userValidator;
private LoginService loginService;
/*
* rest of the controller
*/
}
so the controller must look like this:
@WebMvcTest(UserController.class)
public class UserControllerTest {
@MockBean
private UserRepository userRepository;
@MockBean
private RegisterService registerService;
@MockBean
private UserService userService;
@MockBean
private LoginService loginService;
@MockBean
private UserValidator UserValidator;
/*
* rest of the contoller test
*/
}
Just to make programming less code-monkey, is there anything like @AllMockArgConstructor?
Or any way, I don't always have to add all services?
If this is a stupid question, please explain me why.
Thanks in advance!