JUnit tests always rollback the transactions
It should work, like you expect it, but may be you open another transaction within your class under test or you have an other feature/or bug somewhere.
Btw this annotations should be enougth:
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = {"classpath:com/my/app/context.xml"}@Transactionalpublic class PerformanceTest { @Test @Rollback(false) public void testMsisdnCreationPerformance() { // Create a JPA entity // Persist JPA entity }}
@See Spring Reference Chapter 9.3.5.4 Transaction management
It is strange to desire a test that changes your database and keep the modification.Tests are supposed to be orthogonal : no test depends on an other. Moreover, tests are supposed to be independent of tests order, and even idempotent.
So either you want to change you data base in your setUp()
method and rollback the change in your tearDown()
method, either you want to setup a test database with some good values in it for tests.
Maybe I am missing something here but usually you should not want that.