Resetting autoincrement in h2

前端 未结 3 740
无人及你
无人及你 2021-01-04 20:38

I\'m testing a controller that returns a json response but the tests fail after the first time because the h2 database does not reset the auto increment id. Using fixtures o

3条回答
  •  滥情空心
    2021-01-04 20:55

    If you are using Spring, I found this blog post which suggests using @DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)

    So that each test uses a new application context, thereby resetting the db increments.

提交回复
热议问题