JUnit tests always rollback the transactions

后端 未结 7 1273
死守一世寂寞
死守一世寂寞 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:03

    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.

提交回复
热议问题