In JUnit / Mockito we have 2 extremly useful annotations: @Mock and @InjectMocks.
In my new project i started using groovy with spock for testing, I'm wondering if there is a replacement for mentioned annotations?
There is no real need for @Mock
in Spock, because there is already = Mock()
, which can be used everywhere an annotation can be used (and also in other places). There is an open pull request for @InjectMocks
, but it hasn't been decided if such a feature will make it into spock-core or spock-guice. (Shipping this feature with spock-guice, or at least requiring Guice on the class path, would allow to delegate injection to Guice, rather than reinventing the wheel.) If not, @InjectMocks
could always be shipped as a third-party Spock extension.