jmeter-beanshell本地文件写入多列数据--for循环
Posted 小心走火
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了jmeter-beanshell本地文件写入多列数据--for循环相关的知识,希望对你有一定的参考价值。
1. 首先用一个请求,获取list数据;并且提取出来
这里获取出来的是48个Name,id,color
2. 使用beanshell取样器,循环次数 == ${goodsName_matchNr};可以从debug sample中查看
FileWriter fstream = new FileWriter("/jmeter/src/datacsv/goodsInfofor",true); BufferedWriter out = new BufferedWriter(fstream); //log.info(vars.get("goodsName_${__counter(true,)}").replace(" ","-"));for(int i=1; i<${goodsName_matchNr}+1; i++){ goodsName_i = "goodsName_"+i; // log.info(goodsName_i); String goodsName = vars.get(goodsName_i).replace(" ","-"); goodsId_i = "goodsId_"+i; String goodsId = vars.get(goodsId_i); goodsColorId_i = "goodsColorId_"+i; String goodsColorId = vars.get(goodsColorId_i); goodsColorName_i = "goodsColorName_"+i; String goodsColorName = vars.get(goodsColorName_i); // log.info(goodsName); out.write(goodsName+","+goodsId+","+goodsColorId+","+goodsColorName+"\\n"); } out.close(); fstream.close();
以上是关于jmeter-beanshell本地文件写入多列数据--for循环的主要内容,如果未能解决你的问题,请参考以下文章