- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我最近升级到 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
}
}
最佳答案
我也遇到了这个!很确定它是一个 grails 错误...我提交了一个 jira和一个 patch .
抛出错误是因为 grails.test.spock.IntegrationSpec 中的代码没有检查 interceptor.isTransactional()
调用前 interceptor.destroy()
def cleanup() {
perMethodRequestEnvironmentInterceptor?.destroy()
perMethodTransactionInterceptor?.destroy() //breaks :(
}
...
private GrailsTestTransactionInterceptor initTransaction() {
def interceptor = new GrailsTestTransactionInterceptor(applicationContext)
if (interceptor.isTransactional(this)) interceptor.init() //also need for destroy()
interceptor
}
def cleanup() {
perMethodRequestEnvironmentInterceptor?.destroy()
destroyTransaction(perMethodTransactionInterceptor)
}
...
private void destroyTransaction(GrailsTestTransactionInterceptor interceptor){
if (interceptor?.isTransactional(this)) interceptor.destroy()
}
关于Grails 2.3 IntegrationSpec 不能是事务性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20389973/
我想在测试代码下面不要在测试完成后回滚。 我在mysql上插入了数据,但从未提交。 我使用了 @Rollback 和许多东西,但都没有成功。 测试代码如下。 import grails.test.sp
从2.4.0升级到2.4.2后,运行集成测试时出现错误。它显示测试已通过,但是我收到了IllegalStateException。 Failure: | massemailsystem.Us
我最近升级到 Grails 2.3 并尝试将所有旧测试迁移到 spock 集成测试。但它在清理时失败,因为我的测试是非事务性的。 Grails 文档说测试可以是非事务性的,但我们需要手动处理它,但在这
正在升级到 Grails 3.0.1。除了集成测试在 2.4.4 中运行良好之外,一切都很好。 我注意到 grails.test.spock.IntegrationSpec 不再存在于 org.gra
我正在尝试在 Grails 2.4.4 项目中使用多个数据源。根据文档,这应该是可能的: http://www.grails.org/doc/2.4.4/guide/conf.html#multipl
我在Grails 2.3.6中进行了IntegrationSpec测试,该测试创建任何 Controller 的实例,将数据添加到主体(通过controller.request.JSON),然后验证其
使用 Spock (0.7) Grails (2.1.2) 插件,您可以编写自动注入(inject) Grails 原型(prototype)(如服务)的集成规范。但是,我想对仅在我的 resourc
我所做的是: 安装 Intellij 14(同样的问题也出现在 Intellij 13 上) 为 Intellij 安装 Scala 1.0 插件(支持 Scala、SBT、SSP、HOCON 和 P
我是一名优秀的程序员,十分优秀!