无法在Gatling 3.0模拟中打印线或达到断点

问题描述 投票:-1回答:1

所以我知道我们不能在Gatling模拟之前/之后执行DSL操作,但在3.0中它似乎根本不起作用。如果我运行模拟,我看不到打印线,并且我没有到达打印件上的断点。我正在使用Intellij。我必须遗漏一些明显的东西,任何帮助都会受到赞赏

我的模拟:

    import io.gatling.core.Predef._
import io.gatling.http.Predef._

class Sample extends Simulation {

    val httpProtocol = http
        .baseUrl("https://www.google.com")
        .inferHtmlResources()

    val headers_0 = Map(
        "accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "accept-encoding" -> "gzip, deflate, br",
        "accept-language" -> "en-US,en;q=0.9",
        "cache-control" -> "max-age=0",
        "upgrade-insecure-requests" -> "1",
        "user-agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36")

    def before = {
        println("In the Before")
    }

    def after = {
        println("All done!")
    }

    val scn = scenario("Sample")
        .exec(http("request_0")
            .get("/")
            .headers(headers_0)
    )

    setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}

我正在使用一个对象来运行模拟。如果相关,包括在下面:

import io.gatling.app.Gatling
import io.gatling.core.config.GatlingPropertiesBuilder

object temp {

  def main(args: Array[String]): Unit = {
    val simulation = classOf[Sample].getName
    val runner = new GatlingPropertiesBuilder

    runner.simulationClass(simulation)
    Gatling.fromMap(runner.build)

  }

}
scala gatling scala-gatling
1个回答
0
投票

在椅子上的问题,而不是计算机...下面的解决方案感谢StéphaneLandelle的解决方案。

import io.gatling.core.Predef._
import io.gatling.http.Predef._

class Sample extends Simulation {

    val httpProtocol = http
        .baseUrl("https://www.google.com")
        .inferHtmlResources()

    val headers_0 = Map(
        "accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "accept-encoding" -> "gzip, deflate, br",
        "accept-language" -> "en-US,en;q=0.9",
        "cache-control" -> "max-age=0",
        "upgrade-insecure-requests" -> "1",
        "user-agent" -> "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36")

    before {
        println("In the Before")
    }

    after {
        println("All done!")
    }

    val scn = scenario("Sample")
        .exec(http("request_0")
            .get("/")
            .headers(headers_0)
    )

    setUp(scn.inject(atOnceUsers(1))).protocols(httpProtocol)
}
© www.soinside.com 2019 - 2024. All rights reserved.