Dhr*_*aya 3 junit mockito powermock powermockito
class A {
public B getB(){
// somehow get argType1 and argType2
return new B(argType1, argType2);
}
}
class B{
public B(Type1 t1, Type2 t2){
// something
}
}
Run Code Online (Sandbox Code Playgroud)
我想测试A,并验证该构造函数B获取调用为预期值argType1和argType2。
我如何使用 PowerMockito 做到这一点?
有没有办法像这样传递argumentCaptor:
whenNew(B.class).withArguments(argType1Captor, argType2Captor).thenReturn(somemock);
Run Code Online (Sandbox Code Playgroud)
如果这样做,则argType1Captor获得两个值
我通过这样做解决了它
PowerMockito,verifyNew(B.class).withArgument(expectedArgType1, expectedArgType2)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4646 次 |
| 最近记录: |