5
我有以下代码从DB获取当前计数器值。然后它更新数据库中的计数器,然后再次检索该值。如何在模拟的不同调用中返回不同的值?
int current = DBUtil.getCurrentCount();
DBUtil.updateCount(50);// it updates the current count by adding 50
int latest = DBUtil.getCurrentCount();
我想嘲笑这样的方式第一次调用应该返回100的第二呼叫应当返回150如何使用PowerMockito实现这一目标的静态方法?我正在使用TestNG,Mockito和PowerMock。
为什么'DBUtil'是静态的?注入一个实例,那么你不需要PowerMock。 – durron597