我需要为一个类编写测试用例,该类与以下类似:
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方法,但问题是-我无法跳过调用callWebService()方法,使用PowerMock。因此,更清楚地解释一下,我需要一个测试用例调用loadBean,但在遇到callWebService方法时不做任何操作,继续执行流程。
我在同一网站上阅读了关于使用PowerMockito实现的方法,但无法将其工作。
请帮忙。