【问题标题】:Gatling check does not fail加特林检查不会失败
【发布时间】:2020-09-29 15:06:56
【问题描述】:

我正在尝试发送 http 请求,如果请求返回的不是 200,则失败:

exec(http("Get some html")
      .get("${aggUrl}/somePath")
      .check(status.is(200))
      .check(regex("websocket=(.*?)&").saveAs("wsLink"))
)

服务器发送401响应:

[HTTP/1.1 401 Unauthorized]{"errors":[{"code":"authentication.failure","message":"Failed to authenticate user details"}]}]

我希望在控制台中出现类似“期望代码 200,但是是 401”的内容

但实际的错误是:

[ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-38' crashed with 'j.u.NoSuchElementException: No attribute named 'wsLink' is defined', forwarding to the next one
[ERROR] i.g.h.a.HttpRequestAction - 'httpRequest-37' failed to execute: No attribute named 'wsLink' is defined

所以我假设“.check(status.is(200))”被忽略了?

那我应该怎么考不及格呢?

提前致谢, 安德烈·伊萨科夫

【问题讨论】:

  • 您使用哪个版本的加特林?您是否已升级到最新版本(截至目前为 3.4.0)?
  • 你好斯蒂芬!是的,我使用 gatling 3.4.0: 3.4.03.1.0 4.4.0 gatling 3.3.1 中的行为相同。
  • 其实问题是我看到了regex check的输出,但是没有看到status check的输出。此检查中有一个字段“displayActualValue”,但我不知道如何使用它。编译器总是抱怨。有例子吗?谢谢!

标签: gatling


【解决方案1】:

我认为你错了。

[ERROR] i.g.c.a.b.SessionHookBuilder$$anon$1 - 'hook-38' crashed with 'j.u.NoSuchElementException: No attribute named 'wsLink' is defined', forwarding to the next one
[ERROR] i.g.h.a.HttpRequestAction - 'httpRequest-37' failed to execute: No attribute named 'wsLink' is defined

这些错误发生在您为其提供代码的请求之后,在 exec 块中,您没有提到您尝试检查会话内容并获取 wsLink 的位置由于请求失败而不存在的属性。

检查失败不会以 ERROR 级别记录。您必须降低日志记录级别(请参阅logback.xml)或检查 HTML 报告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-06-05
    • 2020-07-29
    • 1970-01-01
    • 2021-01-27
    • 2023-04-02
    • 2017-04-15
    • 2015-12-20
    相关资源
    最近更新 更多