如何使jmeter从每次迭代的响应中选择唯一值

我收到JMeter的以下回复:

{"tot_cnt":{"tc":"41651","rpp":"100","pdid":"1594"},"mg":[{"id":"683","rsd":"6-May-13 \/ 6-May-13","col":"black","cc":"c_197","pn":"old_NEXUS MARKETING CAMPAIGNS-PERMANENT","loc":"PTD - 07 \/ 18 \/ BX","isf":"1","isl":"0","tq":"180","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/txq8xa56","inv":null,"rbp":"0","pdid":"106","di":"0","pl":"0","spl":null},{"id":"17670","rsd":"6-Jun-13 \/ 6-Jun-13","col":"black","cc":"c_197","pn":"old_NEXUS MARKETING CAMPAIGNS-PERMANENT","loc":"PTD - 07 \/ 18 \/ BX","isf":"1","isl":"0","tq":"180","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/ckwu5qe8","inv":null,"rbp":"0","pdid":"106","di":"0","pl":"0","spl":null},{"id":"22","rsd":"22-Jul-13 \/ 22-Jul-13","col":"black","cc":"c_1884","pn":"old_THE ORTHODONTIC CLINC","loc":"15 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"15","cid":"1992","iq":"0","wid":"WI\/tldj53ky","inv":null,"rbp":"0","pdid":"1582","di":"0","pl":"0","spl":null},{"id":"686","rsd":"29-Jul-13 \/ 29-Jul-13","col":"black","cc":"c_197","pn":"old_NEXUS MARKETING CAMPAIGNS-PERMANENT","loc":"PTD - 07 \/ 18 \/ BX","isf":"1","isl":"0","tq":"180","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/n4olde1g","inv":null,"rbp":"0","pdid":"107","di":"0","pl":"0","spl":null},{"id":"73","rsd":"5-Aug-13 \/ 5-Aug-13","col":"black","cc":"c_2357","pn":"old_KCA DEATAG","loc":"338 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"338","cid":"1914","iq":"0","wid":"WI\/zdqbx1zx","inv":null,"rbp":"0","pdid":"1578","di":"0","pl":"0","spl":null},{"id":"137","rsd":"5-Aug-13 \/ 5-Aug-13","col":"black","cc":"c_1219","pn":"old_TYPHOO - J01-TYPHOO- JULY 2013","loc":"56 - 24 \/ 81 \/ L3","isf":"1","isl":"0","tq":"2","pi":"0","st":"2","dsid":"56","cid":"2090","iq":"0","wid":"WI\/azdtc77c","inv":null,"rbp":"0","pdid":"1086","di":"0","pl":"0","spl":null},{"id":"70","rsd":"12-Aug-13 \/ 12-Aug-13","col":"black","cc":"c_2394","pn":"old_SKF UK LTD","loc":"338 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"338","cid":"1914","iq":"0","wid":"WI\/45uzkvp3","inv":null,"rbp":"0","pdid":"1556","di":"0","pl":"0","spl":null},{"id":"1253","rsd":"12-Aug-13 \/ 12-Aug-13","col":"black","cc":"c_2349","pn":"old_JUST TILES","loc":"PTD - 34 \/ 0M \/ MR","isf":"1","isl":"0","tq":"1","pi":"0","st":"2","dsid":"528","cid":"1955","iq":"0","wid":"WI\/ofunwm5s","inv":null,"rbp":"0","pdid":"1559","di":"0","pl":"0","spl":null},{"id":"1320","rsd":"12-Aug-13 \/ 12-Aug-13","col":"black","cc":"c_2073","pn":"old_NEW COLLEGE SWINDON SUMMER CAMPAIGN","loc":"PTD - 34 \/ 0N \/ RS","isf":"1","isl":"0","tq":"1","pi":"0","st":"2","dsid":"528","cid":"1955","iq":"0","wid":"WI\/gpp1dejn","inv":null,"rbp":"0","pdid":null,"di":"0","pl":"0","spl":null},{"id":"27","rsd":"19-Aug-13 \/ 19-Aug-13","col":"black","cc":"c_2138","pn":"old_WIRED STUDIO PEAK MEGA REAR","loc":"15 - 34 \/ 0N \/ RS","isf":"1","isl":"1","tq":"1","pi":"0","st":"2","dsid":"15","cid":"1992","iq":"0","wid":"WI\/b5m0iyuc","inv":null,"rbp":"0","pdid":"1597","di":"0","pl":"0","spl":null},{"id":"561","rsd":"19-Aug-13 \/ 19-Aug-13","col":"black","cc":"c_3737","pn":"old_LONDON ROAD BRIDGE SCHEME DERBY CITY COUNCIL","loc":"PTD - 83 \/ 4I \/ WB","isf":"1","isl":"0","tq":"1","pi":"0","st":"2","dsid":"527","cid":"1917","iq":"0","wid":"WI\/1s1xaqxw","inv":null,"rbp":"0","pdid":"2574","di":"0","pl":"0","spl":null}

我使用(?=(?:(?!isf).)*?isf":"1)(?=(?:(?!isl).)*?isl":"0)(?=(?:(?!st).)*?st":"2)"id":"(\d+)正则表达式来选择所需的ID。

当我使用5个用户运行测试时,在几次测试中,对于不同的迭代会选择相同的ID,从而导致错误。

我需要让jmeter从每次迭代的响应中提取一些唯一的值。我怎样才能做到这一点?提前致谢。

回答:

在“正则表达式提取器”中,保留设置“匹配号”。为“ 0”

即使ID不够严格,ID也不是唯一的,但它会随机选择不同的值,而不是一次又一次选择相同的值。

使用Bean Shell Sampler 将所有有效的“ ID”写入CSV文件到 ,然后

在 使用创建的CSV运行测试,并为每个请求使用唯一的值。

在分析结果时,您可以忽略第一个线程组。

希望这会有所帮助。

以上是 如何使jmeter从每次迭代的响应中选择唯一值 的全部内容, 来源链接: utcz.com/qa/423016.html

回到顶部