【发布时间】:2019-05-22 10:51:57
【问题描述】:
我需要为此 CustomerEnrollmentSoapServiceImpl 服务编写一个测试用例。如何模拟enrollExtStub.enrollExt() 方法
@Service
public class CustomerEnrollmentSoapServiceImpl implements CustomerEnrollmentSoapService {
@Override
public EnrollExtStub.EnrollExtResponse enrollMember(LoyalHeaders loyalHeaders, EnrollExtStub.Data_type0 enrollMember) {
EnrollExtStub enrollExtStub = new EnrollExtStub();
EnrollExtStub.EnrollExtResponse enrollExtResponse = enrollExtStub.enrollExt(enrollExt, messageHeader);
return enrollExtResponse;
}
}
【问题讨论】:
-
这种场景称为模拟方法本地实例化。使用 powermockito 而不是 mockito。
-
@kswaughs 你能把示例代码作为答案吗
-
添加了我的示例代码。
标签: spring-boot junit mocking mockito