Stubbing or mocking static methods in Java with Spock

前提是你 提交于 2019-12-11 14:32:32

问题


Is it possible to mock static methods in java with spock? I know it is possible to mock static groovy methods but can't get this working for Java methods.


回答1:


No. You need PowerMockito for that. Refactor the class or alternatively wrap the static call in a protected method and stub it out as a spy.



来源:https://stackoverflow.com/questions/56870800/stubbing-or-mocking-static-methods-in-java-with-spock

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!