所以我知道我们无法在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)
}
}
答案 0 :(得分:0)
问题在椅子上,而不是在计算机上...下面的解决方案。感谢StéphaneLandelle提供解决方案。
key