How do I retain the rollback behaviour on DataJpaTest when annotated by @Transactional(propagation = Propagation.NOT_SUPPORTED)

12 Views Asked by At

Similar to How to clean database tables after each integration test when using Spring Boot and Liquibase? I am already using DataJpaTest.

What happened was when I am trying to debug a test file it assumes that there is a transaction that gets rolled back, but the test actually needs to run over multiple transactions provided by a separate Mono.fromCallable with a transactionTemplate that would modify the database and perform locks and wasn't detectable because it was using Schedulers.immediate() during tests.

So what I found was using @Transactional(propagation = Propagation.NOT_SUPPORTED) ensures that the transactions are not implicitly created. But because of it, the database are committed and other tests fail.

I was wondering is there a way to do a "save point" and "restore" during tests rather than using rollback

I've already tried @DirtiesContext no luck.

0

There are 0 best solutions below