我是spock的新手.我正在尝试针对使用JDK 1.7,Spring 3.1,Groovy 1.8.6,Spock 0.6,Maven 3.0.4的独立Java应用程序编写spock单元测试.一个基本的hello world spock测试正在进行中.然而,当我尝试测试春豆时,我发现它们没有被注射.我使用这里提到的方法.businessObjectDao是内空时块.我该如何工作?
@ContextConfiguration(locations = "classpath*:test-appContext.xml")
class BusinessObjectPersistenceTest extends Specification {
@Autowired
BusinessObjectDao businessObjectDao
def "business never set at least once"() {
when:
BusinessObjectDao.getBusinessObject()
then:
...
}
}
Run Code Online (Sandbox Code Playgroud)