带有一个执行链的Gatling场景。请求之后,将保存返回的数据。稍后,它将被处理,并且取决于处理结果,它要么失败,要么通过测试。
这似乎是最简单的可能方案,但我找不到任何可靠的信息,如何在一个exec块内的测试失败。assert打破了场景,似乎是Gatling (如:异常抛出并不仅仅是测试失败)。
示例:
// The scenario consists of a single test with two exec creating the execChain
val scn = scenario("MyAwesomeScenario").exec(reportableTest(
// Send the request
exec(http("127.0.0.1/Request").get(requestUrl).check(status.is(200)).check(bodyString.saveAs("MyData")
// Process the data
.exec(session => {
assert(processData(session.attributes("MyData")) == true, "Invalid data");
})
))上面的场景大致是“卫报失败,关闭系统”。
现在,这似乎是一件有用的、经常使用的事情--我可能遗漏了一些简单的东西。该怎么做呢?
发布于 2014-09-02 11:54:57
您必须遵守Gatling API。
processData,通常在转换可选步骤中执行。发布于 2017-05-30 04:27:56
你是在找像
.exec(http("getRequest")
.get("/request/123")
.headers(headers)
.check(status.is(200))
.check(jsonPath("$.request_id").is("123")))发布于 2021-01-27 06:46:29
因为编辑队列已经满了。
这个问题已经在新版本的Gatling中解决了。3.4.0版
他们补充说
exitHereIf("${myBoolean}")
exitHereIf(session => true)如果条件保持不变,让用户退出这个场景。条件参数是ExpressionBoolean。
https://stackoverflow.com/questions/25622470
复制相似问题