简体   繁体   中英

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

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM