java - Does spring junit rollback by default? -
i'm testing dao layer using spring , junit. test:
@contextconfiguration(locations = "classpath:application-context-test.xml") @runwith(springjunit4classrunner.class) public class testemployeedao { @autowired private employeedao employeedao; @test @transactional public void testinsertemployee(){ employee employee = new employee("abdel karim"); employeedao.insert(employee); . . . } } }
but when execute test , check database find no row inserted, , no exception thrown. don't understand why, default behaviour of spring (springjunit4classrunner) rollback transaction?
thanks in advance.
yes, default rollback true. switch off use:
@test @transactional @rollback(false) public void testinsertemployee(){ employee employee = new employee("abdel karim"); employeedao.insert(employee); }
Comments
Post a Comment