导航:首页 > 文件目录 > jmeter保存响应到文件指定路径

jmeter保存响应到文件指定路径

发布时间:2023-09-24 20:31:58

1. Jmeter进阶三:把数据库的结果处理后保存到本地的文件

import java.io.BufferedWriter;

import java.io.FileWriter;

import java.io.Writer;

import java.util.Random;

import java.util.Arrays;

FileWriter fstream = new FileWriter("D:\\Jmeter\\测试集_rita\\添加产品.csv",false); 

// 1. 设置为true时,从第2行开始插入数据;设置为false时扒枯,从第一行开始插入数据。

// 2. 设置为true时,后面运行时不会覆盖原先的数据;设置为false时,会覆盖原先的数据。

BufferedWriter out = new BufferedWriter(fstream);

Object result=vars.getObject("pro_res");

log.info("结果是"+ result);

int len = result.size();

log.info("个数是"+ len);

String p_ids="";

String p_types="";

String p_grades="";

String p_commerce_types="";

String p_air_conditioning_types="";

for(int i=0;i<len;i++){

    String p_id= result.get(i).get("proct_id").toString();

    String p_type=result.get(i).get("proct_types").toString();

    String p_type2 = p_type.replace(","," ");  /御此念/写入文件时是以“,”区分单元格的,所以得替换原先的符号

    String[] p_type3 = p_type2.split(" ");

    String p_grade= result.get(i).get("grades").toString();

    String p_grade2=p_grade.replace(","," ");

    String[] p_grade3 = p_grade2.split(" ");

    String p_commerce_type= result.get(i).get("commerce_types").toString();

    String p_commerce_type2=p_commerce_type.replace(","," ");

    String[] p_commerce_type3 = p_commerce_type2.split(" ");

    String p_air_conditioning_type=result.get(i).get("air_conditioning_types").toString();

    String p_air_conditioning_type2=p_air_conditioning_type.replace(","," ");

    String[] p_air_conditioning_type3 = p_air_conditioning_type2.split(" ");

     log.info("p_ids为" + p_id);

    log.info("p_types为" + p_type2);

    log.info("p_grades为" + p_grade2);

    log.info("p_commerce_types为" + p_commerce_type2);

    log.info("镇困p_air_conditioning_types为" + p_air_conditioning_type2);

    log.info("长度为" + p_type3.length);

    log.info("长度为" + p_grade3.length);

    log.info("长度为" + p_commerce_type3.length);

    log.info("长度为" + p_air_conditioning_type3.length);

    Random random = new Random();

    int i = random.nextInt(p_type3.length);

    int j = random.nextInt(p_grade3.length);

    int k = random.nextInt(p_commerce_type3.length);

    int l = random.nextInt(p_air_conditioning_type3.length);

    out.write(p_id + ",");

    if (p_type3.length == 1){

        out.write(null + ","); //当属性为空时,需要传null

    }else{

        out.write(p_type3[i].toString() + ",");

    }

    if (p_grade3.length == 1){

        out.write(null + ",");

    }else{

        out.write(p_grade3[j].toString() + ",");

    }

    if (p_commerce_type3.length == 1){

        out.write(null + ",");

    }else{

        out.write(p_commerce_type3[k].toString() + ",");

    }

    if (p_air_conditioning_type3.length == 1){

        out.write(null + ",");

    }else{

        out.write(p_air_conditioning_type3[l].toString() + ",");

    }

}

out.close();

fstream.close();

2. maven jmeter,jmeter 脚本放哪个目录下

linux环境抄还是windows环境? 如果是linux环境,到袭bin目录下:./jmeter.sh XX.jmx(所要运行的测试脚本,没有的话,examples目录下有个) 如果有进程启动,且jmeter.log中没有错误信息就安装成功了; 如果是windows环境,双击“jmeter.bat”文件

阅读全文

与jmeter保存响应到文件指定路径相关的资料

热点内容
ps3文件分割视频 浏览:280
微信图片一键转发软件 浏览:331
如何判断s200plc编程电缆 浏览:691
太原编程培训班哪个好 浏览:171
树叶吹奏教程 浏览:6
社交app带来了哪些社会问题 浏览:394
如何安装爱宝8800数据采集器 浏览:712
文件保存了怎么找不到了 浏览:476
彩票网站怎么辨真假 浏览:840
pr找不到该文件 浏览:963
java移除panel 浏览:354
jsp填充jsp 浏览:166
海关外贸大数据在哪里查 浏览:381
思特奇java笔试题 浏览:121
葫芦侠在手机中的文件名 浏览:813
plc编程应该怎么收钱 浏览:584
c语言中源文件由什么组成 浏览:890
linuxhttpdphp配置文件 浏览:607
拆单数据要怎么保存 浏览:17
mac电脑怎样压缩文件到100m 浏览:645

友情链接