views:

95

answers:

1

I want to create a unit test for integration testing. What class should I inherit to be able to commit/rollback transactions? AbstractTransactionalSpringContextTests is deprecated. It's recommended to use AbstractJUnit38SpringContextTests instead, but I cannot find how to control transactions there.

+3  A: 

Check this and this

In short, you need:

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:/applicationContext.xml")
public class YourTest {

    @Transactional
    public void someTest() {
    }
}

That would mean you need JUnit 4.x

Bozho