I'm new in gatling/scala The main idea of my scenario: I need to pass each item from some prepared List of String into the method, and check that response correct
so it's my scenario
object ForeachScenario extends Scenario {
override def profile(): OpenInjectionStep = {
atOnceUsers(3)
}
val rules_new = List("one", "two", "three")
val custom_feed = rules_new.map(el=> Map("expressions_rules" -> el)).iterator
override def createScenario(): ChainBuilder = {
group(name()) {
tryMax(SCENARIO_MAX_RETRIES) {
tryMax(NUMBER_OF_ATTEMPTS) {
// Creating a user and his context
exec(
UserCreator.createUser(
"userName", "userUid"
)
)
}.exitHereIfFailed
.tryMax(NUMBER_OF_ATTEMPTS) {
feed(custom_feed)
.exec(
someClassWithMethod.method("${userName}", "${userUid}", "request-bodies/rulesDS/rules-expressions.json")
.requestBuilder
.check(status.is(200))
.check(jsonPath("$.evaluations[0].result").find.is("100"))
)
}
}
}
}
}
in general, it works as expected, but... I would like to change this code for using only one virtual user, I have some separate scenario for checking functionality related to UserCreator.createUser and in this case, the main task create a user and under his context check another API, so, for this task user creation for each element in my list is redundantly
override def profile(): OpenInjectionStep = {
atOnceUsers(1)
}
I can't understand how can I realize this, because feeder uses only the first item from the list in the case with one virtual user (atOnceUsers(1)), probably I can save somehow userName and UserUid
exec(
UserCreator.createUser(
"userName", "userUid"
)
)
and use them further OR probably have to use another approach for iteration? can somebody help me with that?