在jmeter中串联响应 [英] Concatenating responses in jmeter

查看:52
本文介绍了在jmeter中串联响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google尝试了很多,但没有找到任何解决方案.如果我错过了,那就对不起.

在Jmeter中,我正在循环运行相同的请求.为"n"次.对于每个请求,我都需要提取json响应并将其传递给下一个请求.我能够提取上一个请求的响应并将其保存到变量中,然后传递给下一个请求.我使用了JSON Path Extractor.我还想出了使用BeanShell和JSR223前后处理器提取响应的方法

这里的事情是我需要提取所有先前的响应数据,并为下一个请求构建请求主体,而不仅仅是最后一个响应.请

我不想将提取的响应附加到文件中,然后将数据传递给文件中的请求.

  Request1(请求正文:[]).回应1:产品ARequest2(请求正文:[产品A]).回应:产品BRequest3(请求正文:[产品A,产品B].响应产品CRequest4(请求正文:[产品A,产品B,产品C]).回应:产品.. .....要求(正文:[产品A,产品B,产品C,产品D] ....),回复:没有其他产品 

请发表任何想法

感谢杰克

解决方案

如果您需要构建

参考文献:

I tried a lot in google and did not find any solution. If I missed then I am sorry.

In Jmeter, I am running the same request in a loop. For 'n' number of times. For every request, I need to extract the json response and pass it to next request. I am able to extract the response of last one request and save it to a variable and then pass to next request. I used JSON Path Extractor. I also figured out extracting the response using BeanShell and JSR223 Pre and Post Processors

The thing here is I need to extract all previous responses data and build the request body for the next request, not just last 1 response. Please

I do not want to append the extracted response to a file then pass the data to request from the file.

    Request1 (Requestbody:[]). Response1: Product A 
    Request2 (Requestbody: [Product A]). Response: Product B 
    Request3 (Requestbody: [Product A, Product B]. Response Product C 
    Request4 (Requestbody: [Product A, Product B, Product C]). Response: Product 
.. ... ..... 
Requestn (body: [Product A, Product B, Product C, Product D]....), response: no more products

Any thoughts please

Thanks Jack

解决方案

If you need to build a JSON Array from previous responses I would recommend consider using JSR223 PostProcessor (assumes Groovy language) and JSONBuilder class for this.

Groovy has built-in JSON support therefore you will have the full flexibility in reading and writing arbitrary JSON structures.

Example:

References:

这篇关于在jmeter中串联响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆