jmeter测试excel导出

1、添加计数器——用户区分导出的文件名称
在这里插入图片描述
2、添加Bean Shell PostProcessor元件
在这里插入图片描述
3、编写Bean Shell脚本——用户将导出的excel保存到本地(原浏览器的工作)
在这里插入图片描述
脚本内容如下:

//JMeter的内置API:prev.getResponseData()获取请求的响应内容
byte[] responseData = prev.getResponseData();

//导出的excel存放位置
private String filePath = “D:/tools/apache-jmeter-2.10/bin/base_base/导出-${index}.xls”;
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try {undefined
File file = new File(filePath);
fos = new FileOutputStream(file); //不添加参数true,以非追加的方式添加内容
bos = new BufferedOutputStream(fos);
bos.write(responseData);
} catch (Exception e) {undefined
e.printStackTrace();
} finally {undefined
if (bos != null) {undefined
try {undefined
bos.close();
} catch (IOException e1) {undefined
e1.printStackTrace();
}
}
if (fos != null) {undefined
try {undefined
fos.close();
} catch (IOException e1) {undefined
e1.printStackTrace();
}
}
}

注意:Synchronizing Timer控件——在这里进行并发控制

运行结果,导出-01.xls----》导出了全部内容

               导出-001.xls----》导出了选中的内容
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值