-1

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

Marcos Vidolin
  • 186
  • 4
  • 21

1 Answers1

1

You should mark your test classes with @Transactional in order to make them rollback automatically after each test.

Vsevolod Poletaev
  • 1,482
  • 1
  • 12
  • 13
  • Thank you Vsevolod. Debugging I saw that the problem was not the conflicts (rollback is ok), but the sequence (id) is increased in each test. How can I fix that? – Marcos Vidolin Oct 08 '16 at 20:13
  • @MarcosVidoli, why do you care about indices? Look here, please http://stackoverflow.com/questions/449346/mysql-auto-increment-does-not-rollback – Vsevolod Poletaev Oct 08 '16 at 22:55