@ Mock / @ InjectMocks for groovy - spock

JUnit / Mockito has 2 extremely useful annotations: @Mock and @InjectMocks .

In my new project, I started using groovy with a spot for testing, I wonder if there is a replacement for the annotations mentioned?

+8
java junit mockito groovy spock
source share
1 answer

There is no real need for @Mock in Spock, because there already exists = Mock() , which can be used wherever annotations can be used (as well as elsewhere). There is an open stretch request for @InjectMocks , but it was not decided whether such a function would turn into spock-core or spock-guice. (Delivering this function with spock-guice, or at least requiring Guice on the way to the class, would allow delegating Guice injections rather than reinventing the wheel.) If not, @InjectMocks can always be sent as a third-party Spock extension.

+10
source share

All Articles