Mock static method with GroovyMock or similar in Spock

前端 未结 3 1648
误落风尘
误落风尘 2020-12-10 12:07

First-timer here, apologies if I\'ve missed anything. I\'m hoping to get around a call to a static method using Spock. Feedback would be great

With groovy mocks, I

3条回答
  •  -上瘾入骨i
    2020-12-10 12:55

    Spock can only mock static methods implemented in Groovy. For mocking static methods implemented in Java, you'll need to use a tool like GroovyMock , PowerMock or JMockit.

    PS: Given that these tools pull of some deep tricks in order to achieve their goals, I'd be interested to hear if and how well they work together with tests implemented in Groovy/Spock (rather than Java/JUnit).

提交回复
热议问题