Re-setting the H2 database in-between tests (i.e. reset DB to my SQL file)

310 views Asked by At

I am attempting to use H2 for my integration tests. I want the H2 database to reset to my data.sql between each test. But in suggested solutions, I have not found to be worked; @Transactional and @DirtiesContext does not seems to be working.

In a @beforeAll, I am setting up a mock queue (using the ElasticMQ library and wondering if this might also causing an issue?).

The Tests work fine when I run them on their own.

Any Thoughts would be greatly appreciated!

1

There are 1 answers

0
C Murphy On

For some reason @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_EACH_TEST_METHOD) solved my problem! I had not tried this earlier as @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD) did not work for me.