JUnit tests always rollback the transactions

后端 未结 7 1221
死守一世寂寞
死守一世寂寞 2020-12-05 02:54

I\'m running a simple JUnit test agains an application DAO. The problem is that I always get:

javax.persistence.RollbackException: Transaction marked as roll         


        
相关标签:
7条回答
  • 2020-12-05 03:28
    I use Junit5, both commit and rollback(false) works with me.
    
        @ExtendWith(SpringExtension.class)
        @SpringBootTest
        @Transactional
        public class MyIntegrationTest {
    
          @Test
          @DisplayName("Spring Boot Will Rollback Data, " +
          "Can Disable it By Add @Commit Or @Rollback(false) Annotation")
          //@Commit
          //@Rollback(false)
          public void test() throws Exception {
           //your test codes here...
          }
    
    0 讨论(0)
提交回复
热议问题