Why isn't my context being injected? The application runs fine. Integration tests using Spring's junit runner and MockMvc run fine. Do I need to add something to integrate Spring and Spock?
@ContextConfiguration(classes = MyConfiguration)
@WebAppConfiguration
class BetaRequestTest extends GebReportingSpec{
@Autowired
WebApplicationContext webApplicationContext; //always null
def setup() {
browser.driver = MockMvcHtmlUnitDriverBuilder
.webAppContextSetup(webApplicationContext).build()
}
def destroy(){
browser.driver?.close()
}
@Test
def void "should render the page"(){
setup:
to BetaRequestPage
expect:
$('h1').value() == "Welcome to Foo"
}
}
Figured it out.
I needed to add the following test dependency:
testCompile "org.spockframework:spock-spring:1.0-groovy-2.4"