【发布时间】:2014-04-02 10:05:45
【问题描述】:
我需要为一个类似于下面的类写一个测试用例:
public class TestClass {
public String loadBean(int i) {
String s = null;
if (i <= 0) {
s = "less";
// call some webservice that we don't need to test
callWebService(s);
} else {
s = "more";
}
return s;
}
private void callWebService(String s) {
//Some complex code here
}
我只需要测试 loadBean 方法,问题是 - 我无法使用 PowerMock 跳过对 callWebService() 的方法调用。因此,为了更清楚地解释,我需要一个调用 loadBean 的测试用例,但在遇到 callWebService 方法继续执行流程时什么也不做。
我在同一个网站上读到它,我们可以使用 PowerMockito 来完成它,但无法让它工作。
请帮忙。
【问题讨论】:
标签: java mockito junit4 powermock