79655112

Date: 2025-06-05 19:24:19
Score: 2
Natty:
Report link

Thank you very much, @krigaex! Indeed, the documentation states that

Groovy mocks should be used when the code under specification is written in Groovy

In other cases

Groovy mocks will behave like regular mocks


Just for more context, when the test is defined as

Mock(HttpRequest, global: true) // simple Mock, not GroovyMock

the following exception is thrown:

org.spockframework.mock.CannotCreateMockException: Cannot create mock for class org.java.HttpRequest because Java mocks cannot mock globally. If the code under test is written in Groovy, use a Groovy mock.
Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @krigaex
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Ilya Pyatizbyantsev