[英]Spock Integration Test fails when run with other integration tests-succeeds in isolation using integration:spock
我正在为grails 2.1.1应用程序的现有测试集添加第一个spock集成测试。 运行时测试运行和测试通过:
grails test-app integration:spock CreditServiceSpec
(是的,一切都在默认包中 - 修复这是一大堆不会被批准的工作......在技术债务下提交。)
但是,当我运行所有测试(grails test-app),单元测试通过,spock单元测试通过,集成测试通过,但我得到以下spock集成失败:
| 完成818次集成测试,0次失败,发生在104001ms | 运行1个spock测试... | 失败:CreditServiceSpec | groovy.lang.GroovyRuntimeException:无法调用构造函数:public org.codehaus.groovy.grails.test.support.GrailsTestAutowirer(org.springframework.context.ApplicationContext),带参数:[] reason:java.lang.IllegalArgumentException at grails.plugin .spock.IntegrationSpec。$ spock_initializeSharedFields(IntegrationSpec.groovy:33)| 完成0 spock测试,0失败33ms | 测试已通过 - 在/ Users / * / projects / GrailsPlugins / DomainServices / target / test-reports中查看报告
无论是运行我构建的完整测试还是以下,我都会得到完全相同的异常,非常简单的示例:
import grails.plugin.spock.IntegrationSpec
class CreditServiceSpec extends IntegrationSpec {
def setup() {}
def cleanup() {}
public void "sample"() {
setup:"Nothing to do here."
expect:"This is the truest of truths..."
true == true
}
}
我确实破解了IntegrationSpec并查看了第33行:
@Shared private autowirer = new GrailsTestAutowirer(applicationContext)
但是确定applicationContext没有被正确传递的方式/原因超出了我的范围,也许是我的问题的主旨。
有没有人遇到过这种行为,并找到了一种方法来使spock集成与其他测试一起玩得很好? 谢谢。
我遇到了完全相同症状的问题。
我正在使用BuildTestData插件并在IntegrationSpec中使用@Build注释,但使用@Build使用转换,扩展了@TestFor转换,这与Intengration运行时不兼容。
所以只需删除@Build注释即可运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.