# How to setup configuration files environments?

**URL:** <https://discuss.akka.io/t/how-to-setup-configuration-files-environments/4320>\
**Category:** Akka Libraries\
**Created:** [June 2, 2019, 7:22am UTC](https://discuss.akka.io/t/how-to-setup-configuration-files-environments/4320 "2019-06-02T07:22:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bifunctor](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/bifunctor/32/1335_2.png) [@bifunctor](https://discuss.akka.io/u/bifunctor)\
**Post date:** [June 2, 2019, 7:22am UTC](https://discuss.akka.io/t/how-to-setup-configuration-files-environments/4320/1 "2019-06-02T07:22:53Z")

</div>

Hi all

I have the following environments:

1. dev
2. stage
3. prod

Each environment will have different configuration and in akka documentation it says, that it is possible to [include files](https://doc.akka.io/docs/akka/current/general/configuration.html#including-files).

> **Including files**  
> Sometimes it can be useful to include another configuration file, for example if you have one application.conf with all environment independent settings and then override some settings for specific environments.
> 
> Specifying system property with `-Dconfig.resource=/dev.conf` will load the `dev.conf` file, which includes the `application.conf`
> 
> ```auto
> include "application"
> 
> ```

akka { loglevel = “DEBUG” }

> ```auto
> 
> ```

My project environment looks as the following:  
[![enter image description here](https://us1.discourse-cdn.com/flex020/uploads/discuss_lightbend/original/2X/2/24ccfdec7637bf9bd062ebced6c95c2974eaa549.png)](https://discuss.akka.io/uploads/short-url/5fynGxiUTNjTfvvsiA2z6gUywOZ.png)

When I do unit test, I would like to use `dev.conf` configuration file and I have to setup somehow, that it will take the `dev.conf` file.

As the doc says above:

> Specifying system property with `-Dconfig.resource=/dev.conf`

It is not clear to me, how to do it. Where do I have to pass it?

The content of my dev.conf looks as the following:

```auto
include "application"

akka {loglevel = "DEBUG"}  

```

The question is, how to make sure, when the unit test is started, that the `dev.conf` file is going use?

Thanks

---

<div class="post-metadata">

**Author:** ![johanandren](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/johanandren/32/85_2.png) [@johanandren](https://discuss.akka.io/u/johanandren)\
**Post date:** [June 19, 2019, 7:19am UTC](https://discuss.akka.io/t/how-to-setup-configuration-files-environments/4320/2 "2019-06-19T07:19:26Z")

</div>

Since sbt by default will run the tests in the same JVM as itself, it is a bit tricky specifying system properties like that, it would require you to switch to forked tests, where a new JVM is started to run the tests.

Another, IMO easier, option is to explicitly select the `dev.conf` in your test cases, for example having a test base class that loads the config with `ConfigFactory.load("dev.conf")` and passes that to the testkit/`ActorSystem` the tests will use.

For the Akka typed testkit we have discussed always loading a specific `application-test.conf` but it has not been implemented yet. ([Issue #25708](https://github.com/akka/akka/issues/25708))
