Mockito错误“系统无法找到指定的路径”

时间:2015-09-11 14:41:34

标签: mockito powermockito

有人可以帮我模拟这个电话吗?

实际代码

final ServicesLocal servicesBean = new WSDelegate().getServiceLocal();

这是我的模拟代码

mockDelegate = mock(PortalDelegate.class);
PowerMockito.whenNew(PortalDelegate.class).withAnyArguments().thenReturn(mockPortalDelegate);

1 个答案:

答案 0 :(得分:2)

您还必须为方法调用添加when

ServicesLocal mockServicesLocal = mock(ServicesLocal.class);
when(mockDelegate.getServiceLocal()).thenReturn(mockServicesLocal);