I'm new to Scala, and I'm struggling with extracting common parts of my gatling tests.
exec(
http("Open Page")
.get("/page")
).exec(
http("GET from REST")
.get("/")
.disableFollowRedirect
.resources(
http("x").get("/rest/x/").check(jsonPath("$.x").exists),
http("y").get("/rest/y/").check(jsonPath("$.y").exists)
)
)
How can I achieve this:
exec(
http("Open Page")
.get("/page")
).exec(
http("GET from REST")
.get("/")
.disableFollowRedirect
.resources(
resources
)
)
val resources = ...???
.resources signature looks like this
def resources(res: HttpRequestBuilder*):
One more though... Since I'm about to unify some resource values that are passed, there usually is something extra that I have to add, what syntax should be used to make below code correct.
exec(
http("Open Page")
.get("/page")
).exec(
http("GET from REST")
.get("/")
.disableFollowRedirect
.resources(
common: _*,
http("z").get("/rest/z/").check(jsonPath("$.z").exists)
)
)
val common: Seq[HttpRequestBuilder] = Seq(
http("x").get("/rest/x/").check(jsonPath("$.x").exists),
http("y").get("/rest/y/").check(jsonPath("$.y").exists)
)
I figured out this
exec(
http("Open Page")
.get("/page")
).exec(
http("GET from REST")
.get("/")
.disableFollowRedirect
.resources(
common:+
http("z").get("/rest/z/").check(jsonPath("$.z").exists): _*
)
)
But maybe there is a "proper" way to do this.