有没有办法在运行时指定要保存在输出文件中的变量列表,而不是在jmeter.properties文件中?
我目前在jmeter.properties文件中指定要保存在sample_variables中的变量列表,但这不允许为每个JMeter脚本指定不同的输出变量集,除非我不断更新jmeter.properties文件。
答案 0 :(得分:0)
我不知道在运行时更改sample_variables的方法。我所知道的唯一解决方法是使用BeanShell Listener(或者可选的一个可编程采样器/前/后处理器),它可以写入自己的文件。 E.g:
String filename = "myfile.txt";
String message = "At " + System.currentTimeMillis() + " data is " + vars.get("myVar");
FileOutputStream f = new FileOutputStream(filename, true);
PrintStream p = new PrintStream(f);
this.interpreter.setOut(p);
print(message);
f.close();
您还可以在保存变量时添加条件(例如,仅在特定采样器之后或仅在值已更改时)。根据我的经验,使用BeanShell Listener的解决方案在资源方面并不昂贵,因为无论运行的线程数是多少,它都将是1个线程。具有可编程预处理器/后处理器的解决方案通常更昂贵,除非您很少保存变量。
答案 1 :(得分:0)
您可以通过sample_variables
命令行参数传递-J
(以及任何其他属性),如:
jmeter -Jsample_variables=foo -n -t script1.jmx
jmeter -Jsample_variables=bar,baz -n -t script2.jmx
另外,根据JMeter用户手册的Managing Properties章节:
当您需要修改jmeter属性时,请确保不修改jmeter.properties文件,而是从jmeter.properties复制该属性并在user.properties文件中修改其值。 / p>
有关不同JMeter属性类型及其使用方式的全面信息,请参阅Apache JMeter Properties Customization Guide文章