Search code examples
javamavenjunithsqldb

Singleton HSQLDB database through tests


Is there anyway to instantiate a singleton HSQLDB database which will live from the first test until the last test finishes in a Maven project?

Actually, my HSQLDB is created in a static class that is been loaded for each test class.

Java 1.7.0_17
JUnit 4.11
HSQLDB 2.2.4


Solution

  • Using a mem: or file: database will preserve the database between tests. See http://hsqldb.org/doc/guide/deployment-chapt.html#dec_app_dev_testing for details and more options.