备课_3.3_jmeter输出变量至指定文件
2018-05-29 本文已影响0人
闫松林
引入jar包
链接:https://pan.baidu.com/s/1A3cD6742ekBNJezgxDRw7Q
提取码:hpij
添加 BeanShell Sampler (写入文件)
import ysl.*;
System.out.println("-----------写入文件---------");
String filePath = "d://test.txt";
String content = vars.get("user");
log.info("-------------"+content);
try {
AppendFile.appendFile(filePath,content);
System.out.println("-----------写入完成---------");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("-----------写入失败---------");
}

添加 BeanShell Sampler (文件初始化)
import ysl.*;
System.out.println("-----------开始初始化---------");
String filePath = "d://test.txt";
try {
AppendFile.clearFile(filePath);
System.out.println("-----------初始化完成---------");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("-----------初始化失败---------");
}
