How to inject spring beans into spock test How to inject spring beans into spock test spring spring

How to inject spring beans into spock test


you most likely forgot to include a Spock Spring dependency.

Here is how to get it using:

maven

<dependency>   <groupId>org.spockframework</groupId>   <artifactId>spock-spring</artifactId>   <version>0.6-groovy-1.8</version></dependency>

gradle

'org.spockframework:spock-spring:0.6-groovy-1.8'

plain groovy

@Grapes(    @Grab(group='org.spockframework', module='spock-spring', version='0.6-groovy-1.8'))

*0.6-groovy-1.8 is the current version, if you need another one, just substitute


For others arriving here that don't have their test class annotated as a Bean (the example in this Question does have sufficient annotation for that), that would of course be at least a necessary prior step for injection (in general).