grails - 在每个测试用例之后是否可能进行Grails IntegrationSpec回滚?

标签 grails integration-testing

因此,我有一个扩展IntegrationSpec的规范,并在setup()方法中创建并保存了一些域对象。在这个规范中,我还有6个测试用例,当分别执行时,它们都可以正常运行。但是,当我执行我的规范中的所有测试用例时,除了第一个用异常(exception),它们都失败了。因此,我想测试用例之间没有回滚。是否可以在每个测试用例之后自动回滚?如果是,如何执行?还是我应该将每个测试用例都放在具有相同设置的单独的集成测试中?

先感谢您。

最佳答案

集成测试在事务中运行,默认情况下,该事务在执行测试后会回滚。

在文档中说:

Integration tests differ from unit tests in that you have full access to the Grails environment within the test. Grails uses an in-memory H2 database for integration tests and clears out all the data from the database between tests.



有关更多信息,请参见Grails Docs - 14.2 Integration Testing

如果您有问题,则必须在此处共享其中一些测试,以便我们进行调查。

关于grails - 在每个测试用例之后是否可能进行Grails IntegrationSpec回滚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27059236/

相关文章:

java - H2:生成插入脚本初始化脚本

java - spring.datasource.data 已获取,但脚本从未执行

c# - asp.net core 数据库集成测试

android - 机器人测试应该是独立的

javascript - 如果其他选择发生变化,则删除并添加选择框选项

使用 React/Flux 的 Grails 项目

database - Grails:处理现有数据库的最佳方法

java - 如何模拟 S3 以在 Junit 中测试 Java 代码

grails - 运行 Liquibase 时出现空值/越界错误

grails - 你如何从你在 spock 中测试的类中模拟出方法