【发布时间】:2015-11-19 10:38:22
【问题描述】:
对于我的项目,我使用:Grails 2.4.4 和 IntelliJ IDEA 14.0.2
我有一个用户域类。我为这个类创建了一个集成测试。这里是:
package com.kunega
import grails.test.spock.IntegrationSpec
class UserIntegrationSpec extends IntegrationSpec {
def setup() {
def appAdmin = new User(username: 'appAdmin', enabled: true, password: 'password').save(flush: true)
}
def cleanup() {
}
void "findUser"() {
expect: User.findByUsername("appAdmin") != null
}
}
当我运行“grail test-app -integration”命令时,IntelliJ 的“运行”选项卡中出现以下错误:
java.lang.IllegalStateException: Could not find ApplicationContext, configure Grails correctly first
at grails.util.Holders.getApplicationContext(Holders.java:97)
at grails.test.spock.IntegrationSpec.$spock_initializeSharedFields(IntegrationSpec.groovy:41)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/grails-2.4.4/dist/grails-plugin-log4j-2.4.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/grails-2.4.4/lib/org.slf4j/slf4j-simple/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.GrailsSlf4jLoggerFactory]
但是,在“控制台”选项卡中有这条消息,表明测试通过了:
|Running 1 integration test... 1 of 1
|Completed 1 integration test, 0 failed in 0m 0s
.
|Tests PASSED - view reports in D:\Facultate\Sport app\Kunega\target\test-reports
我不知道该怎么想。我应该认为测试通过了还是有问题需要解决?如果您需要更多详细信息,例如 BuildConfig.groovy 等,请告诉我。如果有人可以提供解释,那就太好了。谢谢你。
【问题讨论】:
标签: grails intellij-idea groovy integration-testing applicationcontext