Jmeter 响应断言失败
Jmeter response assertion is failing
我有一个 API 请求,成功后我在响应中得到以下标签:
<TktNum xmlns=\"\">12012</TktNum>
并且我将响应断言设置为文本响应,并将模式规则设置为包含文本,如下所述:
<TktNum xmlns=\"\">
但是,即使成功,Jmeter 也无法通过此断言。
我怎样才能让它工作?
谢谢。
根据How to Use JMeter Assertions in Three Easy Steps文章
The most commonly used assertion is the Response Assertion, which checks whether a response text/body/code/message/header contains, matches, or equals a specified pattern.
The Pattern can be either be:
- a “string” for “Equals” or “Substring” clauses
- a “Perl5-style” Regular Expression for “Contains” or “Matches” clauses
所以我认为您需要将您的表达方式修改为:
<TktNum xmlns=\"\">(\d+)</TktNum>
更多信息:
Select 模式匹配规则部分中的选项 Substring
。
Equals, Substring: plain text, case-sensitive
如果您想继续使用 Contains
选项,您需要在转义字符 ``` 前加上另一个 \
<TktNum xmlns=\"\">
我有一个 API 请求,成功后我在响应中得到以下标签:
<TktNum xmlns=\"\">12012</TktNum>
并且我将响应断言设置为文本响应,并将模式规则设置为包含文本,如下所述:
<TktNum xmlns=\"\">
但是,即使成功,Jmeter 也无法通过此断言。
我怎样才能让它工作?
谢谢。
根据How to Use JMeter Assertions in Three Easy Steps文章
The most commonly used assertion is the Response Assertion, which checks whether a response text/body/code/message/header contains, matches, or equals a specified pattern.
The Pattern can be either be:
- a “string” for “Equals” or “Substring” clauses
- a “Perl5-style” Regular Expression for “Contains” or “Matches” clauses
所以我认为您需要将您的表达方式修改为:
<TktNum xmlns=\"\">(\d+)</TktNum>
更多信息:
Select 模式匹配规则部分中的选项 Substring
。
Equals, Substring: plain text, case-sensitive
如果您想继续使用 Contains
选项,您需要在转义字符 ``` 前加上另一个 \
<TktNum xmlns=\"\">