문제

If I were to annotate my DAO integration test methods with @Transactional, Spring Test will happily rollback any changes to the database after each test methods completes. These seems extremely convenient, because I can load the test data once with a @BeforeClass method and all clean up is handled for me.

But I question whether this is a good practice because I'd be missed the opportunity to uncover failures that would occur during a commit. Whats the consensus on using transactions in dbunit integration tests of DAOs to help with clean up??

도움이 되었습니까?

해결책

This is perfectly fine. You will perform write operations on your unit-tests, and the DB will verify those operations. They won't be committed, but this last step would never fail because of business logic, so you should not worry about that.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top