Search code examples
scalagatlingscala-gatling

Gatling request is not getting executed


    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)

But When I run the Gatling tests the request is not being sent, and the whole HTTP block is ignored. Where am I going wrong?

So I am end up with the following exception.

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)


Solution

  • I fixed it myself.

          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"))
    
            })