jmeter导出结果报告

jmeter导出结果报告,第1张

注意如果不是空的文件夹是会报错的姿和

也可以将其他结果都填写这一个csv文件进行导出

注意毕缺这里的文件内容一定是

使用命令生成:jmeter -n -t C:\Users\sj176\Desktop\测试用户系统.jmx -l C:\Users\sj176\Desktop\testdd.csv -e -o C:\Users\sj176\Desktop\test01\

在生成的时候可能会报错

org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 1 is not equal to fixed size 5

不过注意的是java版本如果太高可能会报

Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5

安装兼容的java版本即可,

查看jdk安装版本,发现是17系列的迹数盯。在网上查看教程发现需要更换成jdk8系列,具体安装步骤参照网上。

猜测应该是jdk17的兼容性问题。

打开结果展示:

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=0i<leni++){

    String p_id= result.get(i).get("product_id").toString()

    String p_type=result.get(i).get("product_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()


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/12241201.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-22
下一篇 2023-05-22

发表评论

登录后才能评论

评论列表(0条)

保存