我正在使用Mockito进行单元测试。但是当我尝试调用假客户端时,它总是返回null而不是模拟对象。
高级客户
@FeignClient(url = "${Users.details}",name = "userDetails")
public interface UserDetails {
public Object getUserDetails(@RequestHeader Map<String, Object> headers, @RequestParam Map<String,
Object> requestParams);
}
测试方法
@InjectMocks UserServices userServices;
@Mock UserServicesRest userServicesRest;
Object mockUserDetails = "UserDetails Data";
@Test
public void driverData() {
Mockito.when(userServicesRest.getUserDetails(Mockito.anyMap(),Mockito.anyMap())).thenReturn(mockUserDetails);
}
请提前帮助谢谢。