0
我嘲笑使用PowerMockito REST调用的私有方法。PowerMockito嘲笑私有方法抛出异常,但返回预期的响应
PowerMockito.doReturn(response).when(notificationService, "sendNotification", anyString());
当测试运行时,它提供了模拟响应和断言工作,如我所料。
然而,在测试中,我看到:
java.net.MalformedURLException
at java.net.URL.<init>(URL.java:627)
因为嘲笑私有方法可以执行:
private NotificationResponse sendNotification(String notification) {
URL url = new URL(exampleURL);
// more code
}
如何避免模拟的方法执行?
有什么办法可以避免方法执行吗? – Justas