Modularizing simulation - define checks in separate file / import checks from another file?

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 and 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) => {


and the main simulation:

val scn = scenario(…)


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 {
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?

No, check is a method on http request, you can’t move it around.
What you can move around is the list of checks that you pass to the check method.

Disclaimer: yes, this looks weird, don’t blame me, don’t blame Scala. Blame damn Java’s type erasure.


can be turned in:

import io.gatling.http.check.HttpCheck

val myChecks: Seq[HttpCheck] = Seq(,

.check(myChecks: _*)

Awesome! This works perfectly, thanks!

Can you combine individual checks and sequences in the call to check()? E.g.:

val myChecks: Seq[HttpCheck] = Seq(


myChecks: _*

Apparently not:

… no `: *’ annotation allowed here
(such annotations are only allowed in arguments to *-parameters)
15:23:16.784 [ERROR] i.g.a.ZincCompiler$ - .check(,mAddToCartChecks:

However, this works:

.check(( HttpCheck) +: checks: _*))