3
votes

I have a Play application that defines three different connection configurations in conf/reference.conf. When I run unit tests that require the use of FakeApplication the BoneCP plugin automatically initializes these three connections even when the unit tests do not call any classes that use any database connections. It starts up and shuts down connections for every unit test. This causes unit tests to take forever to complete. Is there a way to lazily start database connections in BoneCP, HikariCP, or some other connection manager, only opening them when they're first used?

I could of course disable BoneCPPlugin altogether inside the relevant unit tests, but what if I have a unit tests that needs one of the connection configurations?

1
If it needs a database connection, is it really a unit test?millhouse
You're right, it's an integration test, not a unit test. However, They're being invoked as unit tests right now so I'm looking for a solution until we get a chance to move them to a separate integration test suite.Alex
Also, even if we separate these as proper integration tests, we'll still run into the same performance problems.Alex
You can have a look at acolyte.eu.org for persistence (not DB) unit testing.cchantep

1 Answers

1
votes

For HikariCP, just set initializationFailFast=false and minimumIdle=0.