如何在 jmeter 中保存整个响应消息

how to save whole response message in jmeter

我在 jmeter 中收到以下响应-

[{"Status":"Failed","ErrorDesc":"Duplicate Transaction Id","Amount":"23","CorporateID":"aaa","StatusCode":"ERR0DUP"," TransactionReferenceNumber":"1111"}]

我需要保存整个响应消息。 我尝试使用 listner,也使用 csv 文件,但只有 b 能够保存响应,如 - OK,true

请帮我按原样保存整个回复。

如果您想将响应保存到变量中,只需使用 Boundary Extractor with empty left and right boundaries or Regular Expression Extractor and (?s)(^.*) regular expression, see The Boundary Extractor vs. the Regular Expression Extractor in JMeter 文章了解更多详细信息,以了解更多关于这两个家伙的差异。

示例设置:

在上面的设置中,整个响应将保存到 JMeter 变量中,您可以在需要时将其引用为 ${response}

如果您想将响应保存到文件中 - 寻找 Save Responses to a file 侦听器,将其添加为 returns 响应的请求的子项并像这样配置它:

以上配置会将父采样器的整个响应存储到 JMeter 安装的“bin”文件夹中的 response.txt 文件中

您可以通过以下配置使用将响应保存到文件采样器

  1. 确保“不向前缀添加号码”复选框未选中
  2. 设置序列号的最小长度(例如6)

您可以尝试使用以下选项来获得唯一的文件名

  1. 检查添加时间戳

  2. 使用${__threadNum}and/or${__threadGroupName} 文件名字段

    响应-${__threadGroupName}-{__threadNum}.json