I have an .exec which for some values in my parameter list results in KO (value does not exists in the SUT). I further have the need to print these values to a file so I later can remove them from the parameter list in order to not get KO`s. I have a writer defined
val writer = {
val fos = new java.io.FileOutputStream("testresultater.txt")
new java.io.PrintWriter(fos,true)
}
and wonder how I could do this just for KO s inside the .exec resulting in KO
s for some values like this:
.exec(http("request_lagDokument")
.post("/proxy/dokumenter/api/v1/SaveDokumentFil?IsDebug=true")
.headers(headers_3)
.body(ElFileBody("magnus/LagDokument.json"))
.check(status.is(expected = 200))
.check(jsonPath("$.DokumentGuid").saveAs("DokumentGuid")))
//if KO then:
.exec((s: Session) => {
writer.println(s.attributes("pnr"))
s
})
Is this possible?
You can do this by having a session function that is always executed with the conditional logic inside
.exec(session = {
if (session.isFailed) {
writer.println(s.attributes("pnr"))
}
session
})
or you can use the dsl's doIf
.doIf(session => session.isFailed) {
exec(session => {
writer.println(s.attributes("pnr"))
session
}
}
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.