Search in sources :

Example 1 with SpockMockPostprocessor

use of org.spockframework.spring.mock.SpockMockPostprocessor in project spock by spockframework.

the class SpringMockTestExecutionListener method prepareTestInstance.

@Override
public void prepareTestInstance(SpringTestContext testContext) throws Exception {
    Object testInstance = testContext.getTestInstance();
    if (!(testInstance instanceof Specification))
        return;
    ApplicationContext applicationContext = testContext.getApplicationContext();
    if (applicationContext.containsBean(SpockMockPostprocessor.class.getName())) {
        SpockMockPostprocessor mockPostprocessor = applicationContext.getBean(SpockMockPostprocessor.class);
        mockPostprocessor.injectSpies(testInstance);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) Specification(spock.lang.Specification) SpockMockPostprocessor(org.spockframework.spring.mock.SpockMockPostprocessor)

Aggregations

SpockMockPostprocessor (org.spockframework.spring.mock.SpockMockPostprocessor)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Specification (spock.lang.Specification)1