val makeReport =
feed(randomNumberFeeder)
.exec( session => {
http("post_report")
.post("/api/path/reports")
.body(StringBody(JsonFactory.report(id = 1, number= session("number").asOption[String].get))).asJson
.check(jsonPath("$.reportId").saveAs("reportId"))
session
})
val scn = scenario("ReportCreation").exec(makeReport)
但是当我运行Gatling测试时,请求没有发送,整个HTTP块都被忽略。我要去哪里错了?
所以我遇到了以下异常。
Exception in thread "main" java.lang.UnsupportedOperationException: There were no requests sent during the simulation, reports won't be generated
at io.gatling.charts.report.ReportsGenerator.generateFor(ReportsGenerator.scala:50)
at io.gatling.app.RunResultProcessor.generateReports(RunResultProcessor.scala:65)
at io.gatling.app.RunResultProcessor.processRunResult(RunResultProcessor.scala:40)
at io.gatling.app.Gatling$.start(Gatling.scala:89)
at io.gatling.app.Gatling$.fromArgs(Gatling.scala:45)
at io.gatling.app.Gatling$.main(Gatling.scala:37)
at io.gatling.app.Gatling.main(Gatling.scala)
答案 0 :(得分:1)
我自己修复了。
val makeReport =
feed(randomNumberFeeder)
.exec(http("post_report")
.post("/api/path/reports")
.body(StringBody( session => JsonFactory.report(id = 1, number= session("number").as[String]))).asJson
.check(jsonPath("$.reportId").saveAs("reportId"))
})