简体   繁体   中英

Spring boot 1.4 test with h2database (rollback in each test)

I'm new on testing and I'm running a @DataJpaTest (spring boot 1.4). I have some tests running right but I want all the tests perform a rollback before start an other to avoid h2database errors or conflicts.

I'm using a general "import.sql" file to insert some common data at startup and I'm doing some inserts in each test.

Thank you

您应该使用@Transactional标记您的测试类,以便在每次测试后自动回滚它们。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM