简体   繁体   中英

passing in multiple checks as variable arguments in Gatling

I would like to have the ability to pass in checks to a method that makes a gatling post. I am having some issue doing so. I tried using a few different types on the checks but had no luck. I would like to have something like the below on a "page" object that would be used elsewhere in the app. I think I briefly saw there are other types of checks beyond status based checks. I would like the method to be flexible enough to handle such things if possible.

protected val commonChecks = Seq(status.not(404),status.not(503))
def login(checks:HttpCheck = commonChecks) = {
  exec(http("post login")
    .post("/login")
    .headers(someheader)
    .formParam("login", "${userName}")
    .formParam("password", "${password}")
    .check(commonChecks) //.check(commonChecks: _*) don't work
  )

}

What if you explicit the type of commonChecks :

protected val commonChecks: Seq[HttpCheck] = Seq(status.not(404),status.not(503))
def login(checks:HttpCheck = commonChecks) = {
  exec(http("post login")
    .post("/login")
    .headers(someheader)
    .formParam("login", "${userName}")
    .formParam("password", "${password}")
    .check(commonChecks: _*)

  )

IntelliJ seems to infer the following type otherwise: Seq[CheckBuilder[HttpCheck, Response, Response, Int] with SaveAs[HttpCheck, Response, Response, Int]] which causes the compilation error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM