使用 jmeter 将提取的数据写入文件 [英] Write extracted data to a file using jmeter

查看:62
本文介绍了使用 jmeter 将提取的数据写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 JMeter v2.5.
我需要从测试的响应中获取数据并从中提取数据(我正在使用常规的 exp 提取器).如何将此提取的数据存储到文件中?

I am using JMeter v2.5.
I need to get data from the responses of the test and extract data from it (which I am doing using regular exp extractor). How do I store this extracted data to a file?

推荐答案

刚解决了一个类似的问题.使用正则表达式提取器获取数据后,添加一个 BeanShell PostProcessor 元素.使用以下代码将变量写入文件:

Just solved a similar problem. After getting the data using a regular expression extractor, add a BeanShell PostProcessor element. Use the code below to write the variables to a file:

name = vars.get("name");
email = vars.get("email");

log.info(email);  // if you want to log something to jmeter.log file

// Pass true if you want to append to existing file
// If you want to overwrite, then don't pass the second argument
f = new FileOutputStream("/my/file/path/result.csv", true);
p = new PrintStream(f); 
this.interpreter.setOut(p); 
print(name + "," + email);
f.close();

这篇关于使用 jmeter 将提取的数据写入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆