How to rollback a database transaction when testing services with Spring in JUnit?

前端 未结 4 419
有刺的猬
有刺的猬 2020-12-01 03:19

I have no problem testing my DAO and services, but when I test INSERTs or UPDATEs I want to rollback the transaction and not effect my database.

4条回答
  •  遥遥无期
    2020-12-01 04:03

    If your

    myService.addPerson("JUNIT"); 
    

    method is annotated like @Transactional you will be getting some different kind or errors trying to fix this. So you better just test DAO methods.

提交回复
热议问题