Creating temporary database that works across maven test phases?

后端 未结 2 1350
走了就别回头了
走了就别回头了 2020-11-30 14:09

I\'ve joined a project that has a lot of files with SQL statements for creating a database that is used for integration testing.

I\'m wondering how I can use these f

2条回答
  •  有刺的猬
    2020-11-30 15:02

    1. Why not create an on-disk H2 database, and have each test access it? So long as the tests don't run in parallel or interact with each other, you don't need a server.

    2. Even more so: just create memory databases in @Before and delete them in @After. Are you sure that's too slow?

    3. In pre-integration-test, you could launch an H2 (or derby) server, and shut it down in post-integration-test.

    4. You can write a maven plugin that uses session state to keep track of an embedded database service, but that's much the same as (3).

提交回复
热议问题