Grails集成测试设置和junit注释
我在复杂GROUPBY/having子句的代码中有一些EXECUTEQUY,所以我需要一个集成测试用例来测试它。使用了Grails2.1.1 然而,我发现了几个问题: 1.测试前不会自动调用setUp方法。 2.因此,我将@Before注释添加到setUp方法中,现在可以调用它了。但是现在不能使用executeQuery语句Grails集成测试设置和junit注释,grails,integration-testing,Grails,Integration Testing,我在复杂GROUPBY/having子句的代码中有一些EXECUTEQUY,所以我需要一个集成测试用例来测试它。使用了Grails2.1.1 然而,我发现了几个问题: 1.测试前不会自动调用setUp方法。 2.因此,我将@Before注释添加到setUp方法中,现在可以调用它了。但是现在不能使用executeQuery语句 java.lang.UnsupportedOperationException: String-based queries like [executeQuery] are
java.lang.UnsupportedOperationException: String-based queries like [executeQuery] are currently not supported in this implementation of GORM. Use criteria instead.
似乎我不能在集成测试中使用任何注释。否则它会变成一个单元测试用例吗?如果不使用任何注释,则测试通过
下面是代码示例
class JustTests extends GroovyTestCase {
void setUp() {
log.warn "setup"
}
void tearDown() {
log.warn "cleanup"
}
void "test something"() {
// Here is the code to invoke a method with executeQuery
}
}
谢谢。您确定您的测试在
test\integration
文件夹中吗?是的。我很肯定。因为它适用于没有注释的executeQuery。您是否使用@TestFor
注释?不。我不使用任何注释来通过测试。Grails 2.3.5也存在此问题。考虑以下问题:两个测试都会失败,但在任何断言中都会中断,并询问MyDealm是什么,它将不会为空。