Spring boot Integration test data clean up issue
I have some integration tests in my spring boot tests. Around 20 of them. Before each integration test I am using @Sql annotation to inject some data and after the test I run a clean up script to truncate all the tables. So, my 20 tests case runs perfectly when I run them together. No issues. Now I have added a new integration test. Using the same process here too. Injecting some data at startup and cleaning the data with script. This test case runs perfectly but some how the data conflicts with other test cases.@AfterEach test I am running the clean up script similiar to the other testcases, but in this testcase some how the data starts persisting and conflict with other tests. If I comment this 21th test case, then again everything starts working just fine. I using the default surfire plugin that comes with springboot-maven-plugin. So, far the only solution I found is using @DirtiesContext with the test case that is causing the issue. But I don’t understand why is it necessary. My clean up scripts works fine(I can see that it is running via show-sql). Then why would my test case conflict with another.