JMeter:为响应断言显示断言失败消息

JMeter: Assertion Failure Message is displayed for Response Assertion

我是第一次尝试响应断言,并显示以下错误:

Assertion error: false
Assertion failure: true
Assertion failure message: Test failed: text expected to contain /(?is)<title>Management Information System</title>/

出现这种错误的原因是什么?

Assertion error: false 行表示没有发生内部 jmeter 错误。

Assertion failure: true 行表示您设置要检查的断言条件为假。

Test failed: text expected to contain /(?is)Management Information System/ 行意味着您设置断言以检查断言的目标(很可能是响应主体)是否与正则表达式匹配 /(?is)Management Information System/ 但它确实匹配没有。

第一个假设:为什么需要这个(?is)位?在 "Contains" 模式下,如果删除 Response Assertion 应该可以正常工作。

根据How to Use JMeter Assertions in 3 Easy Steps指南

The Pattern can be either be:

a “string” for “Equals” or “Substring” clauses

a “Perl5-style” Regular Expression for “Contains” or “Matches” clauses

第二个假设:如果您希望它仅适用于 所有 请求,则根据您的图片断言其中之一将其移动为该特定请求的子项。

在 JMETER 中:如果您看到 2 Response Assertion 选项卡,则删除其中一个 Response Assertion(要测试的模式)就可以了 然后再试一次它会起作用