码迷,mamicode.com
首页 > 系统相关 > 详细

jmeter-beanshell本地文件写入多列数据--for循环

时间:2020-06-29 16:54:30      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:dwr   shell   get   fstream   sid   dsc   str   new   mat   

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循环

标签:dwr   shell   get   fstream   sid   dsc   str   new   mat   

原文地址:https://www.cnblogs.com/nieliangcai/p/13208628.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!