Running sbt test suite twice causes jdbc Driver not found error Running sbt test suite twice causes jdbc Driver not found error sqlite sqlite

Running sbt test suite twice causes jdbc Driver not found error


It appears that the Setup.bootstrap method, which claims the database in the Eclair library, relies upon the JVM exiting to clean-up after it, and doesn't appear to provide a mechanism for allowing you do so manually at the end of your test. (If there is such a mechanism, using that would do the trick too.)

By default, tests run in the same JVM that the SBT build instance runs in, so the resources claimed in the first run of the test are still present when you run the test a second time. Except that, on the second and subsequent runs, they're unable to claim the database resources because they're already claimed.

By adding:

fork in Test := true

to your SBT build, you're forcing each test instance to run in its own JVM instance, so it can start afresh each time.