# \[Java\] Dynamically setup scenario for simulation

**URL:** <https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692>\
**Category:** Gatling (Open-Source)\
**Created:** [April 20, 2022, 10:26am UTC](https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692 "2022-04-20T10:26:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSlaski](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@MSlaski](https://community.gatling.io/u/MSlaski)\
**Post date:** [April 20, 2022, 10:26am UTC](https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692/1 "2022-04-20T10:26:54Z")

</div>

Hello,

I would like to know if one thing is possible to implement. I have two classes with simulations e.g.  
LoadTest and CapacityTest.

At both classes I don’t have any implementation of Scenario. Scenarios implementations are stored at different classes as a Static ScenarioBuilder objects. Those Objects can be used at Simulations classes and know I’m not sure if it is possible.

I want to start my tests using mvn CLI. I know that I can provide a Simulation class which should be triggered but how to configure scenario for it?

I think it can be done via some additional configuration file and for example additional script which can according to input prepare data at configuration file and after that trigger test using mvn CLI

Do you know any other solution for this case?

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [April 20, 2022, 10:55am UTC](https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692/2 "2022-04-20T10:55:13Z")

</div>

Hi MSlaski,

I’m not sure to understand the question.

**Scenario** defines the journey of a single user. (say AdminScenario, LurkerScenario, CustomerScenario, etc.)  
**Simulation** defines the actual test, ie. how many users are injected for each scenario.

So, it makes sense to launch one `Simulation` class, but there is no meaning to launch a `Scenario` from the CLI.

Perhaps you want to multiply your simulation definitions and give them more meaningful names?

- `HeavyPeakOfCustomerSimulation` (with lots of customers and some lurkers)
- `CapacitySimulation` with a constant ratio of Admins, Lurkers and Customers but the total amount increasing too reach the breaking point.
- `MemoryTest` with small amount of each kind but during a very long time.

etc.

Note that the injection profiles (arguments of `setUp` method in your Simulation) can reference variables that you loads or compute from environment variables or Java System Properties.

Does that helps?

Cheers!

---

<div class="post-metadata">

**Author:** ![MSlaski](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@MSlaski](https://community.gatling.io/u/MSlaski)\
**Post date:** [April 20, 2022, 11:09am UTC](https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692/3 "2022-04-20T11:09:50Z")

</div>

I will try to clarify

I have two scenarios: two different user journeys  
And I want to use them at two different test types: capacity and load.  
Differences between load and capacity are the way how injection will be implemented

And now I want to start one of simulation from CLI (load or test) and somehow inject particular scenario (first user journey or second user journey). Scenarios will be not triggered together

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [April 20, 2022, 11:53am UTC](https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692/4 "2022-04-20T11:53:26Z")

</div>

So, you should create 4 different simulations:

- `User1CapacitySimulation` =\> a simulation that will inject scn1 for capacity test
- `User2CapacitySimulation`
- `User1LoadSimulation`
- `User2LoadSimulation`

As you will have 4 different classes, you will be able to launch each one separately.

Cheers!

---

<div class="post-metadata">

**Author:** ![MSlaski](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@MSlaski](https://community.gatling.io/u/MSlaski)\
**Post date:** [April 20, 2022, 12:01pm UTC](https://community.gatling.io/t/java-dynamically-setup-scenario-for-simulation/6692/5 "2022-04-20T12:01:39Z")

</div>

Thank you very much!
