我对使用JMeter进行测试还很陌生。我有一个JSON块,我想用我从以前的GET请求中创建的三个数组中的值填充它。结构类似于这样:
"books": [
{
"publisher": ${publisherName}, //variable but it's the same for all items in this request
"ISBN": ${isbn_1}, //the next three are from from 3 different arrays
"Price": ${price_1},
"Publisher": ${publisher_1},
"Static Value that doesn't change": 100
},
{
"publisher": ${publisherName}, //variable but it's the same for all items in this request
"ISBN": ${isbn_2}, //the next three are from from 3 different arrays
"Price": ${price_2},
"Publisher": ${publisher_2},
"Static Value that will be the same for all items": 100
},
],
有没有一种方法可以循环动态地添加块,以便我可以在一个请求中发送所有这些项?
2条答案
按热度按时间aamkag611#
您可以使用任何合适的JSR223测试元素和Groovy来完成它
如果没有看到你的“数组”看起来像什么,很难提出一个全面的解决方案,JSON结构可以像这样创建:
生成的值可以存储到JMeter变量中,如:
并在以后需要时用作
${payload}
更多信息:
t5zmwmid2#
我假设你有3个不同的数组,大小相同,分别是
ISBN
,Price
,Publisher
。您将代码写入JSR223 Pre-Processor