【发布时间】:2012-09-14 22:25:14
【问题描述】:
我遇到了一个关于 java 中的类模拟的问题。
我将使用虚拟类来解释问题(以避免与项目相关的安全问题) 我们有一个 Employee 类
public class Employee {
public int netSalary() {
int sal = totalSal() - 100;
return sal;
}
public int totalSal() {
// code to return value which is making db calls or remote calls
}
}
现在我的问题是如何在不调用 totalSal 方法的情况下测试 netSalary 方法 我已经尝试过 expect().andReturn() 以及 suppress(method());
但两者都不起作用
【问题讨论】:
标签: class junit mockito easymock powermock