[英]reason: no instance(s) of type variable(s) T exist so that void conforms to T
I want to do nothing when cloudWatchRuleDestroy.destroy(@NonNull String ruleName) function of another class is called.当调用另一个类的 cloudWatchRuleDestroy.destroy(@NonNull String ruleName) 函数时,我什么也不想做。
I have tried Mock and InjectMocks but "cloudWatchRuleDestroyer.destroy(any())" makes the compiler show "reason: no instance(s) of type variable(s) T exist so that void conforms to T"我尝试过 Mock 和 InjectMocks 但“cloudWatchRuleDestroyer.destroy(any())”使编译器显示“原因:不存在类型变量 T 的实例,因此 void 符合 T”
public void testHandleRequest() {
doNothing().when(cloudWatchRuleDestroyer.destroy(any()));
handler.handleRequest(inputMap);
}
How to avoid this compiler error?如何避免这个编译器错误? What is the change I need to make?
我需要做出什么改变?
Syntax of brackets is wrong.括号的语法是错误的。
Correct Syntax:正确的语法:
doReturn(someObject)
.when(someInstance)
.someMethod();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.