PowerMockito 验证称为 x times 的私有方法
2022-09-03 07:34:37
我正在使用并模拟私有方法:PowerMockito
spy
final SomeClass someClass = new SomeClass();
final SomeClass spy = PowerMockito.spy(someClass);
PowerMickito.doReturn("someValue", spy, "privateMethod1");
final String response = Whitebox.invokeMethod(spy, "anotherPrivateMethod");
// I can now verify `response` is of the correct data
// But I also want to verify `privateMethod1` was called x times or so
我不知道如何验证我的方法是否被调用了x次。
附注
是否最好只创建我所有的私有方法,然后在我的测试类中扩展该类并执行此操作?protected