当前位置: 首页 > news >正文

JMeter快速造数之数据导入导出

导入数据

  • 输入表格格式如下

  • 创建CSV Data Set Config

  • 在Body Data中调用
{
"username": "${email}",
"password": "123456",
"client_id": "00bb9dbfc67439a5d42e0e19f448c7de310df4c7fcde6feb5bd95c6fac5a5afc",
"scope": "all",
"react_app_request": true
}

导出数据

  • 创建BeanShell PostProcessor
    • 一般数据来源是接口的response内容
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
import org.json.JSONObject;
import org.json.JSONArray;String response=prev.getResponseDataAsString();//取出接口的返回消息
JSONObject jsonstring=new JSONObject(response);//放进json对象里String token=jsonstring.getString("refresh_token");
String email=jsonstring.getJSONObject("profile").getString("email");
String type=jsonstring.getString("user_type");
String school=jsonstring.getJSONObject("profile").getJSONObject("school").getString("name");
token = "Bearer " + tokenString outputFile = "E:/Software/JMeter/tokenInfo.csv";
// before we open the file check to see if it already exists
boolean alreadyExists = new File(outputFile).exists();try {// use FileWriter constructor that specifies open for appendingCsvWriter csvOutput = new CsvWriter(new FileWriter(outputFile, true), ',');// if the file didn't already exist then we need to write out the header lineif (!alreadyExists){csvOutput.write("Email");csvOutput.write("Token");csvOutput.write("Type");csvOutput.write("School");csvOutput.endRecord();}// else assume that the file already has the correct header line// write out a few recordscsvOutput.write(email);csvOutput.write(token);csvOutput.write(type);csvOutput.write(school);csvOutput.endRecord();csvOutput.close();
} catch (IOException e) {e.printStackTrace();
}

备注:可以创建一个Debug PostProcessor进行调试代码

http://www.lryc.cn/news/477803.html

相关文章:

  • 框架学习01-Spring
  • Java | Leetcode Java题解之第539题最小时间差
  • 126页PPT麦肯锡战略实施与成本优化:质效提升与精益采购实践
  • Modbus解析流程全面升级:体验全新核心与终极优化!
  • 【MWorks】Ubuntu 系统搭建
  • 安装Element-Plus与v-model在vue3组件中的使用
  • Qt学习笔记第41到50讲
  • 加固筑牢安全防线:多源威胁检测响应在企业网络安全运营中的核心作用
  • 用Python将PDF表格提取到文本、CSV和Excel文件中
  • AIGC在游戏设计中的应用及影响
  • 给初学者的 Jupyter Notebook 教程
  • 搜维尔科技:Xsens和BoB助力生物力学教育
  • Vue动态计算Table表格的高度
  • 【MongoDB】MongoDB的聚合(Aggregate、Map Reduce)与管道(Pipline) 及索引详解(附详细案例)
  • 数组和字符串的es6新方法使用和综合案例
  • JS语法进阶第一课!—DOM(重点)
  • Swift 开发教程系列 - 第5章:集合类型
  • Spring:Bean(创建方式,抽象继承,工厂Bean,生命周期)
  • Flutter中的Extension关键字
  • transformers 框架使用详解,bert-base-chinese
  • STM32——ADC
  • Unity SRP学习笔记(二)
  • 数据库第五次作业
  • 健身房业务流程优化:SpringBoot解决方案
  • 【产品经理】工业互联网企业上市之路
  • Java学习教程,从入门到精通,Java对象和类语法知识点(20)
  • 金融场中的量化交易:民锋数据驱动策略的优势解析市
  • Docker 配置镜像加速
  • HTTP慢速攻击原理及解决办法
  • 【系统面试篇】进程和线程类(1)(笔记)——区别、通讯方式、同步、互斥、锁分类