如何在JMeter上设置嵌套的ForEach Controller并发送子请求

时间:2019-01-22 09:21:04

标签: jmeter jmeter-plugins jmeter-5.0

我有3种请求,

request 1: www.test.com/data  

将返回JSON数组中的数据

 request 2: www.test.com/img/{img_id} 

{img_id}来自请求1返回的项目,请求2将返回{uid}

 request 3: www.test.com/test/{uid}

我使用jmeter测试此流,现在我能够发送请求1并 然后使用ForEach Controller发送一些请求2,但是我不根据每个请求2的响应发送请求3

我是JMeter的新手,有人可以帮忙吗,谢谢

1 个答案:

答案 0 :(得分:1)

您需要再添加一个嵌套在上一个ForEach Controller中。 因此您的测试计划结构将如下所示:

Thread Group  
    Request 1  
        RegExpExtractor 1  
    ForEach Controller 1  
        Request 2  
            RegExpExtractor 2
        ForEach Controller 2  
            Request 3

您可以将Regular Expression Extractor-1用作Match No.参数,以在ForEach Controller中使用它(从RegExpExtractor 1ForEach Controller 1以及从{{1} }到RegExpExtractor 2)。

以这个Test Plan为例。