'In a Spring-Boot integration test of a REST interface call, how can I roll back the server side transaction?

Given I am in a Springboot JUnit integration test which calls a REST controller method of the same spring application context using a TestRestTemplate, how can I make sure that the application server calls to the database are in the same transaction as the unit test and are rolled back after the test?

My test is marked as @Transactional, and in the log of the test I can see that a transaction is started and rolled back later. Still I see records created/changed on the database by the application under test.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source