Junit 如何修复org.mockito.exceptions.misusing.MissingMethodInvocationException:
当我运行测试方法时,我得到了以下输出: org.mockito.exceptions.misusing.MissingMethodInvocationException: when需要的参数必须是“模拟的方法调用” 例如:Junit 如何修复org.mockito.exceptions.misusing.MissingMethodInvocationException:,junit,mocking,mockito,Junit,Mocking,Mockito,当我运行测试方法时,我得到了以下输出: org.mockito.exceptions.misusing.MissingMethodInvocationException: when需要的参数必须是“模拟的方法调用” 例如: when(mock.getArticles()).thenReturn(articles); 此外,出现此错误的原因可能是: 您可以存根:final/private/equals/hashCode方法。 这些方法无法存根/验证。 当您不在mock上调用方法,而是在其他对象上
when(mock.getArticles()).thenReturn(articles);
此外,出现此错误的原因可能是:
您可以存根:final/private/equals/hashCode方法。
这些方法无法存根/验证。
当您不在mock上调用方法,而是在其他对象上调用方法时。
@试验
//@Ignore在与生成一起运行时失败
当NimNotReady引发ApplicationException、SystemException时,公共无效失败{
Map rabbitMqProperties=newhashmap;
rabbitMqProperties.putamqp.addresses,10.20;
rabbitMqProperties.putamqp.virtualhost,/pc;
rabbitMqProperties.putamqp.username,Deejay;
rabbitMqProperties.putamqp.password,deephouse;
rabbitMqProperties.putamqp.port,9805;
System.getProperties.putAllrabbitMqProperties;
UserCredentials UserCredentials=新的UserCredentials;
userCredentials.setUserID989864;
userCredentials.setAuthenticationSystemdjp;
EnterpriseMessageHeader EnterpriseMessageHeader=新的EnterpriseMessageHeader;
enterpriseMessageHeader.setUserCredentialsuserCredentials;
LaunchAppRequest LaunchAppRequest=新的LaunchAppRequest;
启动apprequest.setUcn4848;
启动AppRequest.setHeaderenterpriseMessageHeader;
当nuserlogon.isUserLoggedInanyString时,anyString.thenReturnBoolean.TRUE;
当OICE.lead.THEN返回76584L时;
当连接FactoryProvider.getVocalist.thenReturnmockVocalist.class时;
LaunchAppResponse响应=AppLogicBean.launchApplaunchAppRequest;
assertFalseresponse.isSuccessful;
assertEqualsresponse.getErrorMessage、MusicProducer.PROXY\u MSG;
}
实际上,您有两个错误: 当OICE.lead.THEN返回76584L时; 当连接FactoryProvider.getVocalist.thenReturnmockVocalist.class时; 您正在尝试模拟静态方法。Mockito不能用于模拟静态方法。如果你真的想这么做,你应该仔细看看