Reputation: 371
So I have a spec that extends IntegrationSpec and I create and save some domain objects in my setup() method. I further have 6 testcases in this spec which all run fine when exectued individually. But when I execute all testcases in my spec they all fail except the first one. So I guess there is no rollback done in between the testcases. Is it possbile to rollback automatically after each testcase and if so, how? Or am I supposed to put each test case into a seperate integration test with the same setup?
Thank you in advance.
Upvotes: 1
Views: 1424
Reputation: 1615
Integration tests are running in a transaction that is rolled back after test execution by default.
In the docs it says:
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.
For further information see Grails Docs - 14.2 Integration Testing.
If you have problems you would have to share some of these tests here so that we can take a look into it.
Upvotes: 1