@MockBeans 有类似 Lombok @AllArgConstructor 的东西吗?

Is there anything like Lombok @AllArgConstructor for @MockBeans?

我将 Project Lombok 用于我的 Java 个项目。

我的控制器看起来像这样:

@RestController
@AllArgsConstructor
public class UserController {

    private RegisterService registerService;
    private UserService userService;
    private UserValidator userValidator;
    private LoginService loginService;
    /*
     * rest of the controller
     */
}

因此控制器必须如下所示:

@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
     */
}

只是为了减少代码猴子的编程,有没有类似@AllMockArgConstructor 的东西?
或者,我不必总是添加所有服务?

如果这是一个愚蠢的问题,请解释原因。

提前致谢!

很遗憾,无法完成,

@MockBeans annotation target is applied only to fields and types, and not for methods, you can read more about it here.


如果 @MockBeans 也能够支持方法,那么就可以这样做:

@Getter(onMethod_={@MockBean} )
@WebMvcTest(UserController.class)
public class UserControllerTest {
   ...
}