模拟Runtime.getRuntime() - Spring Boot -Junit
我尝试使用以下代码模拟我的Runtime.getRuntime():
PowerMockito.mockStatic(Runtime.class);
PowerMockito.when(Runtime.getRuntime()).thenReturn(mockRuntime);
但是我有以下错误:
org.mockito.exceptions.misusing.MissingMethodInvocationException:
when() requires an argument which has to be 'a method call on a mock'.
I tried to mock my Runtime.getRuntime() with the following code :
PowerMockito.mockStatic(Runtime.class);
PowerMockito.when(Runtime.getRuntime()).thenReturn(mockRuntime);
But I had the following error :
org.mockito.exceptions.misusing.MissingMethodInvocationException:
when() requires an argument which has to be 'a method call on a mock'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您可以尝试以下尝试:
I think you can try like below: