如何忽略加特林中失败的请求

时间:2019-09-09 20:35:28

标签: scala gatling

我有一个加特林性能脚本来测试注销页面。进入主页后,我将请求发送到注销页面。 https://..../logout.html的请求为200 OK。

.exec(http("getHomepage")
                .get("https://.../home/home.jsp")
                .silent
                .check(status.find.in(200))
                .check(bodyString.saveAs("responseBody"))
                .headers(headers_1))
              .exec(http("getLogoutPage")
                .get("https://..../logout.html")
                .headers(headers_1))

但是,当调用GET https://..../logout.html时,它还会有其他一些请求,例如.js,.css,.png。其中一些人得到404。

>getLogoutPage                     (OK=14     KO=0     )
>XD-IMG-Warn.png                   (OK=0      KO=13    )

错误:

[WARN ] i.g.h.a.ResponseProcessor - Request 'XD-IMG-Warn.png' failed: status.find.in(200,304,201,202,203,204,205,206,207,208,209), but actually found 404 XD-IMG-Warn.png的错误并不重要,我只关心getLogoutPage结果。所以我的问题是在运行测试期间如何忽略此错误?

1 个答案:

答案 0 :(得分:0)

对于您不关心结果的请求,您可以将其标记为静默,这样它们就不会包含在报告中,也不会导致KO。

要执行此操作,您可以在不希望报告的任何请求之后将.silent链接起来

文档在regex option

中有详细说明