我试图将通配符传递给mockito any()方法.这是方法
selectGatewayInfoConfig(Operation<?> o)
Run Code Online (Sandbox Code Playgroud)
我想要做的是:
when(gatewayConfigSelector.selectGatewayInfoConfig( any(**!!!!!! HERE I NEED THIS WILDCARD !!!!**));
.thenReturn(...something...);
Run Code Online (Sandbox Code Playgroud)
提前致谢.
怎么样?
when(gatewayConfigSelector.selectGatewayInfoConfig( any(Operation.class));
.thenReturn(...something...);
Run Code Online (Sandbox Code Playgroud)
例:
@Test
public void test() {
Tester mock = Mockito.mock(Tester.class);
Mockito.when(mock.selectGatewayInfoConfig(Mockito.any(Operation.class))).thenReturn("blah");
System.out.println(mock.selectGatewayInfoConfig(null));
}
class Operation<T> {
}
class Tester {
public String selectGatewayInfoConfig(Operation<?> o) {
return "hi";
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5161 次 |
| 最近记录: |