Can we somehow replicate the behavior of Spring @T...
# exposed
a
Can we somehow replicate the behavior of Spring @Transactional in tests? So that the transaction will be rolled back after each test
z
I've done this using a junit extension (using
BeforeEachCallback
and
AfterEachCallback
. In the beforeEach method you do something like
TransactionManager.manager.newTransaction()
and in the afterEach you do
Copy code
override fun afterEach(context: ExtensionContext?) {
        with(TransactionManager.current()) {
            rollback()
            closeExecutedStatements()
            close()
        }
    }
🙏 1
a
thanks I will try that!