I’ve got a simulation that’s doing most of the things I want thus far, and now I am breaking it up into separate modular bits so that I can then call them a variable number of times (i.e. I can simulate a random number of products being added to a cart, etc, by just looping a random number of times and calling the add to cart code repeatedly).
using a mixture of information from https://stackoverflow.com/questions/15568284/modularising-scenarios-to-run-in-sequence-using-gatling and https://github.com/excilys/gatling/wiki/Advanced-Usage this is working for the purposes of running an entire section :
in the imported add to cart file:
object AddToCart {
val mAddToCartAction =
exec((session: Session) => {
…
}
.exec(
http(…)
)
.exitHereIfFailed
.pause(…)
}
and the main simulation:
…
val scn = scenario(…)
.exec(…)
…
.exec(mAddToCartAction)
…
For purposes of organization / readability, it would be nice if checks that are used to gather data for an action could be separated into the action’s scala file, rather than being in the previous action’s scala file, and just import them and exec similarly. I tried to do this but got errors about “not found: value check”:
AddToCart.scala:18: not found: value check
13:51:19.900 [ERROR] i.g.a.ZincCompiler$ - check(css("#product_addtocart_form",“action”).find.saveAs(“formAction”))
the referenced line being:
15 object AddToCart {
16
17 val mAddToCartChecks =
18 check(css("#product_addtocart_form",“action”).find.saveAs(“formAction”))
I tried wrapping it in exec too but that didn’t change anything…
Is this possible? If so, how?