问题
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