Grails3:运行集成测试后出现IllegalStateException

Grails3:运行集成测试后出现IllegalStateException,grails,integration-testing,gorm,grails-3.0,grails-3.1,Grails,Integration Testing,Gorm,Grails 3.0,Grails 3.1,我在运行集成测试时不断遇到异常: 导入grails.testing.mixin.integration.integration 导入grails.transaction.Rollback 导入org.springframework.beans.factory.annotation.Autowired 导入spock.lang.Specification @整合 @回滚 类规范扩展了规范{ @自动连线 电子邮件服务 //def设置(){ // } // //def cleanup(){ //

我在运行集成测试时不断遇到异常:

导入grails.testing.mixin.integration.integration
导入grails.transaction.Rollback
导入org.springframework.beans.factory.annotation.Autowired
导入spock.lang.Specification
@整合
@回滚
类规范扩展了规范{
@自动连线
电子邮件服务
//def设置(){
//    }
//
//def cleanup(){
//    }
def“测试发送电子邮件”(){
何时:“发送电子邮件”
def sendMailCalled=false
service.metaClass.sendTestEMail={
sendMailCalled=true
}
service.sendTestEMail(“test@myprovider.de")
然后:
sendMailCalled==true
}
}
结果:

"C:\Program Files\Java\jdk1.8.0_112\bin\java" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.4\lib\idea_rt.jar=49498:C:\Program Files\JetBrains\IntelliJ IDEA 2017.2.4\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\user\AppData\Local\Temp\classpath.jar com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit4 "de.mypackeage.EmailSpec,test send email"

java.lang.IllegalStateException: No GORM implementations configured. Ensure GORM has been initialized correctly

    at org.grails.datastore.gorm.GormEnhancer.findSingleDatastore(GormEnhancer.groovy:380)
    at org.grails.datastore.gorm.GormEnhancer.findSingleTransactionManager(GormEnhancer.groovy:399)
    at de.mypackeage.EmailSpec.test send email(EmailSpec.groovy)




Process finished with exit code -1
测试已经顺利运行了,但我真的不知道为什么它不会再运行了。感谢您的任何帮助


这个项目是用Grails3.3.1建立的,问题是我在IntelliJ中作为JUnit测试执行了这个测试。因此grails上下文没有启动,导致了错误。

问题是我在IntelliJ中作为JUnit测试执行了测试。因此grails上下文没有启动,导致了这个错误。

我经常从IntelliJ运行集成测试

如果编辑配置(右上)->Defaults->JUnit 将VM选项设置为-Dgrails.env=test-ea

这将使“测试”配置文件能够在intellij中执行


希望有帮助。

我经常从IntelliJ运行集成测试

如果编辑配置(右上)->Defaults->JUnit 将VM选项设置为-Dgrails.env=test-ea

这将使“测试”配置文件能够在intellij中执行

希望能有帮助