# Passing parameter to the simulation from SBT

**URL:** <https://community.gatling.io/t/passing-parameter-to-the-simulation-from-sbt/2915>\
**Category:** Gatling (Open-Source)\
**Created:** [April 12, 2016, 3:08pm UTC](https://community.gatling.io/t/passing-parameter-to-the-simulation-from-sbt/2915 "2016-04-12T15:08:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yann\_Moisan](https://avatars.discourse-cdn.com/v4/letter/y/3d9bf3/32.png) [@Yann\_Moisan](https://community.gatling.io/u/Yann_Moisan)\
**Post date:** [April 12, 2016, 3:08pm UTC](https://community.gatling.io/t/passing-parameter-to-the-simulation-from-sbt/2915/1 "2016-04-12T15:08:32Z")

</div>

I launch my test using sbt and task it:test.

I use the same Simulation to test on 3 different env.

Is there a way to pass the env to the Simulation, without launching again sbt ?

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [April 12, 2016, 3:27pm UTC](https://community.gatling.io/t/passing-parameter-to-the-simulation-from-sbt/2915/2 "2016-04-12T15:27:35Z")

</div>

The way I have done it is to use a Typesafe Config that reads an environment variable, and then my Gatling code references the config variable, and reacts accordingly.

My config looks like this:

`test { environment = "dev" environment =${?TEST_ENVIRONMENT} // this will override the value of environment if and only if the variable is set }`

Then I read it with code like this:

`  
object Test {  
private lazy val userConfig = ConfigFactory.load()  
private lazy val environmentConfig = ConfigFactory.load( “environment.conf” ) // the file referenced above  
private lazy val config = userConfig.withFallback( environmentConfig )

lazy val environment = config.getString( “test.environment” )  
}  
`

What this lets me do is, I can do nothing, and it will default to the value in “environment.conf”. Or, I can create an “application.conf” file and put it in my class path, and in it I can create an override for test.environment. OR, I can create an environment variable TEST\_ENVIRONMENT, and that value will override the value stored in “environment.conf”

Then, whenever I need to know the name of the environment, I simply type “Test.environment”. I then use the value of that string to build the path to an environment-specific config file, which tells me the URLs to hit, etc.

That help?

---

<div class="post-metadata">

**Author:** ![aidylewis](https://avatars.discourse-cdn.com/v4/letter/a/e9a140/32.png) [@aidylewis](https://community.gatling.io/u/aidylewis)\
**Post date:** [April 12, 2016, 3:50pm UTC](https://community.gatling.io/t/passing-parameter-to-the-simulation-from-sbt/2915/3 "2016-04-12T15:50:15Z")

</div>

[https://gist.github.com/aidylewis/ff12f6a243b1a2b83f021e4d6401442c](https://gist.github.com/aidylewis/ff12f6a243b1a2b83f021e4d6401442c)
