使用jmeter将提取的数据写入文件 [英] Write extracted data to a file using jmeter
本文介绍了使用jmeter将提取的数据写入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从测试的响应中获取数据,并从中提取数据(我使用常规的exp提取器)。如何将提取的数据存储到文件?
解决方案
刚刚解决了类似的问题。在使用正则表达式提取器获取数据之后,添加一个BeanShell PostProcessor元素。使用下面的代码将变量写入文件:
name = vars.get(name);
email = vars.get(email);
log.info(email); //如果你想把某些东西记录到jmeter.log文件
//如果你想追加到现有文件
,则传递true //如果你想覆盖,那么不要传递第二个参数
f = new FileOutputStream(/ my / file / path / result.csv,true);
p =新的PrintStream(f);
this.interpreter.setOut(p);
print(name +,+ email);
f.close();
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?
解决方案
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屋!
查看全文