Search code examples
akkaakka-persistence

How to use other application.conf in tests than in prod code?


im trying to test PersistentActor with scalatest but I dont know how to point test code to use something like application-test.conf instead application.conf ( I want to change leveldb store for events to in memory store ). Is there any convenient way to do this?


Solution

  • You could define another application.conf in your test resources:

    src/test/resources/application.conf

    This way, you can have test related configuration that will be used by default in your tests.

    If you still require multiple configuration settings among your tests, you can always have more than one configuration file in the test resources and explicitly use the one you need:

    class PersistentActorSpec extends TestKit(ActorSystem("test-system", ConfigFactory.load("application-test")))