我最近升级到 Grails 2.3 并尝试将所有旧测试迁移到 spock 集成测试。但它在清理时失败了,因为我的测试是非事务性的。Grails 文档说测试可以是非事务性的,但我们需要手动处理它,但这里似乎不太合适。因为我在扩展 IntegrationSpec 的每个集成测试中都遇到了这个错误
java.lang.IllegalStateException: Cannot deactivate transaction synchronization - not active
at grails.test.spock.IntegrationSpec.cleanup(IntegrationSpec.groovy:72)
像这样的简单测试会抛出该错误:
import grails.test.spock.IntegrationSpec
public class DummySpec extends IntegrationSpec {
static transactional = false
def setup() {
}
def cleanup() {
}
def testDummy() {
expect:
1 == 1
}
}