使用jmeter将提取的数据写入文件

Jig*_*wda 17 file-io jmeter

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

ami*_*ena 34

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

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();
Run Code Online (Sandbox Code Playgroud)

  • 另外这个 [link](https://ansonliao.gitbooks.io/jmeter-skill/content/jmeter_how_to_save_variables_to_a_file_after_getting_the_data_using_a_regular_expression_extractor.html) 可能会有所帮助。 (2认同)

Mat*_*ewJ 1

你有几个选择

  1. 您可以通过向线程组添加聚合报告侦听器 => 添加侦听器 => 聚合报告来统计结果
  2. 您可以通过向线程组添加简单的数据写入器侦听器 => 添加侦听器 => 简单数据写入器来获取原始结果

希望这可以帮助