Junitデータベース操作時のトランザクションの自動ロールバック

2520 ワード

 Junit service , , , , 
    @Test
    public void testAddOrUpdateUserEmail() {
        Long result = (long) userService.addOrUpdateUserEmail("777", "127.0.0.1", 
                " -test", " ", "aa");
    }
juni , debug , , :
@Test
    public void testAddOrUpdateUserEmail() {
        Long result = (long) userService.addOrUpdateUserEmail("777", "127.0.0.1", 
                " -test", " ", "aa");
        User user = userMapper.selectByPrimaryKey("770517");
        System.out.println("------>user:" + user.getUsername() + user.getEmail());
    }
 debug , , , Junit AbstractTransactionalJUnit4SpringContextTests
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:app-initconfig-excdubbo-test.xml" })
public class BaseExcludeDubboTest extends AbstractTransactionalJUnit4SpringContextTests{
    /**
     * @description 
     */
    @Test
    public void testEmpty(){

    }
}
AbstractTransactionalJUnit4SpringContextTests 、 、 , , , @Rollback(false) 。