[Java] Population Builder usage

Hello,

setUp method can be used with List argument. I would like to know how to configure PopulationBuilder. In my case I want to setUp scenarios names from env variables, after reading scenarios name I would like to use proper static ScenarioBuilders objects. For that the best way (from my opinion) will be to use with setUp method the List of PopulationBuilders. Details about users will be also configurable via env vars

Do you have any code snippets with usage of PopulationBuilder?

BR
Mateusz

perhaps found solution:

        this.setUp(List.of(
                scenario1.injectOpen(atOnceUsers(5)).protocols(httpProtocol),
                scenario2.injectOpen(atOnceUsers(5)).protocols(httpProtocol)
        ));

protocols and injections will be the same, so if there is a way to simplify that, I will try to figure it out.
Now List of scenarios is hardcoded but I have to prepare some Factory class which will return proper list according to scenarios provided as a env var

if there is a way to simplify that

public class BasicSimulation extends Simulation {
  HttpProtocolBuilder httpProtocol = ...
  ScenarioBuilder scenario1 = ...
  ScenarioBuilder scenario2 = ... // May be defined in another class as well

  {
    List<PopulationBuilder> populations = List.of(
      scenario1.injectOpen(atOnceUsers(5)),
      scenario2.injectOpen(atOnceUsers(5))
    );
    setUp(populations).protocols(httpProtocol)
  }
}

Cheers!

1 Like