selva4
February 8, 2023, 11:02am
1
let me brief what i am looking to do it.
1.they are two scenario which list out below for your reference,
val matchProxyCompany: ScenarioBuilder = scenario{
xxxx
}
val matchProxyPerson: ScenarioBuilder = scenario{
xxxx
}
here i am doing mapping the string name → with the given scenario
val scenarioByName: Map[String, ScenarioBuilder] = Map(
"matchProxyPerson" -> matchProxyPerson,
"matchProxyCompany" -> matchProxyCompany,
)
### sample variable for your reference
injectionNames=matchProxyPerson
ScenarioList=Map[matchProxyPerson,1]
val injections = for {
name <- injectionNames
scn = scenarioByName(name)
defaultUsers <- ScenarioList.get(name)
} yield scn.inject(atOnceUsers(defaultUsers))
setUp(injections).protocols(gatlingVariableConfig.httpConf)
}
looking to build the below one automatically as i have given the given the string name and scenario name are same
using the injectionNames
val scenarioByName: Map[String, ScenarioBuilder] = Map(
"matchProxyPerson" -> matchProxyPerson,
"matchProxyCompany" -> matchProxyCompany,
)
for example - sample code
// trying to get the existing scenario object by the it string name
for (int i=0,i>injectionNames.length,i++)
{
val scenarioByName: Map[String, ScenarioBuilder] = Map(
injectionNames[i] -> scenarobuilder.getobject[injectionNames[i]],
)
}
i would appreciate that if you pour some suggestion
selva4
February 8, 2023, 1:13pm
3
Thanks for your time and prompt reply,
i have two scenario,
matchProxyPerson
matchProxyCompany
our script is designed such a way, we can execute both scenario as individual scenario, scenario selections are given to injectionNames
example 1, want to run “matchProxyPerson” scenario for test, i will pass the below value
injectionNames=matchProxyPerson
example 2, want to run the both scenarios, i will pass the two values
injectionNames=matchProxyPerson,matchProxyCompany
Based on the number of items in “injectionNames”. - variable
below codes will generation the injections
val injections = for {
name ← injectionNames
scn = scenarioByName(name)
defaultUsers ← ScenarioList.get(name)
} yield scn.inject(atOnceUsers(defaultUsers))
setUp(injections).protocols(gatlingVariableConfig.httpConf)
}
selva4
February 8, 2023, 1:19pm
4
let me come into the problem
below code help us to map ---------
scenarioName in string object —> scenarioName in scenario builder
val scenarioByName: Map[String, ScenarioBuilder] = Map(
“matchProxyPerson” → matchProxyPerson,
“matchProxyCompany” → matchProxyCompany,
)
let say, i want to add one scenario
matchProxyScoops
Hi @selva4 ,
What you want is a way to parse your injectionNames variable into an Iterable?
So a question about string manipulation in scala?
What about split ?
If so, this is not a question for our Gatling community.
Otherwise, magically find all available scenarii and their name, it’s either impossible or only by reflection and again, out of scope of Gatling community.
Cheers!
selva4
February 8, 2023, 1:22pm
6
i would need to make one more entry here
val scenarioByName: Map[String, ScenarioBuilder] = Map(
“matchProxyPerson” → matchProxyPerson,
“matchProxyCompany” → matchProxyCompany,
“matchProxyScoops” → matchProxyCompany
)
what i am looking here and below code should be automated when we add a new scenario
val scenarioByName: Map[String, ScenarioBuilder] = Map(
“matchProxyPerson” → matchProxyPerson,
“matchProxyCompany” → matchProxyCompany,
“matchProxyScoops” → matchProxyCompany
)
selva4
February 8, 2023, 1:25pm
7
@sbrevet thanks and will look into reflection topic
Hey there,
Can I ask whether or not it would be easier to develop in Java rather than Scala?
All the best,
Pete
system
Closed
March 10, 2023, 1:50pm
9
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.