Avoid opening unused database connections in Play

I have a Play app that defines three different connection configurations in a conf/reference.conf

. When I run unit tests that require use FakeApplication

, the BoneCP plugin will automatically initialize these three connections, even if the unit tests do not call classes that use any database connections. It starts up and disconnects connections for each unit test. This causes the unit tests to run forever. Is there a way to lazily start database connections in BoneCP, HikariCP or some other connection manager, only opening them when they are first used?

I could of course disable the BoneCPPlugin completely inside the respective unit tests, but what if I have unit tests that need one of the connection configurations?

+3


source to share


1 answer


For HikariCP, just install initializationFailFast=false

and minimumIdle=0

.



+1


source







All Articles