因此,我有一个扩展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/