αƞjiβ
αƞjiβ

Reputation: 3246

Scala integration test not picking config properties

I have an Scala project with integration test with following folder structure

My Project
  - app
  - it
    - com.anjib.my.pkg
    - resources
      - application.regression.devl.conf

I want to overwrite one of the properties by putting in application.regression.devl.conf file but while running integration test its still pulling top level property.

For example some where in project there is

someKey=someValue

I put

somekey=otherValue 

in application.regression.devl.conf. But integration tests are still picking someValue

My build.sbt looks like

lazy val `my-project` = (project in file("."))
  ....
  .configs( IntegrationTest )
  .settings( Defaults.itSettings : _*)
  ....

)

Config loading as

def apply(): Config = {
  val environment = determineEnvironment
  val defaultConfig = ConfigFactory.load()
  val envConfig: Config = ConfigFactory.load(s"application.$environment.conf")
  val regressionSuiteConfig = ConfigFactory.load(s"application.regression.$environment.conf")
  regressionSuiteConfig.withFallback(envConfig).withFallback(defaultConfig)

}

Update: ID I do Ctrl + Shift + F10 in IntelliJ it did pick up otherValue. So it has issue only with sbt it:test

Upvotes: 0

Views: 444

Answers (1)

insan-e
insan-e

Reputation: 3921

Try to set the javaOptions in sbt like this:

javaOptions in IntegrationTest += "-Dconfig.resource=" + System.getProperty("config.resource", "application.regression.devl.conf")

With this sbt will set the config.resource parameter to "application.regression.devl.conf" if nothing is passed explicitly.

Upvotes: 1

Related Questions