【发布时间】:2015-04-25 14:24:47
【问题描述】:
我正在使用带有基于 java 的配置的 spring boot。我有以下类结构
@Service
public class Service implements IService{
@autowire
private IProcessor processor;
public void perform(Parameter param){
processor.process(param);
}
}
@Service
public class Processor implements IProcessor {
@autowire
private ProxyFactory factory;
public void process(Parameter param){
final ExternalSysProxy proxy = factory.get(param.getValue(), param.getId());
proxy.call();
}
}
@Repository
public class ProxyFactory {
public Proxy get(String value, String id){
final ExternalSysProxy proxy = new proxy(value, id);
return proxy;
}
}
这里的代理对象调用外部系统。我想通过模拟代理对象来编写集成测试。您能否给我一些指导,如何在这个结构中注入模拟代理对象。
【问题讨论】:
标签: java spring unit-testing mocking integration-testing