如何在变量中获取 JMX Jmeter 文件名的名称 [英] How to get the name of JMX Jmeter filename in a variable
问题描述
我想在侦听器中使用jmeter测试脚本的名称(.jmx),以便以动态方式生成结果文件.您能告诉我为此目的的 Jmeter 变量是什么吗?
I want to use the name of the jmeter test script (.jmx) in a listener so as to generate the result file in a dynamic way. Can you please tell me what is the Jmeter variable for that purpose?
使用了无效的 ${fileName}
Used ${fileName} which didn't work
推荐答案
您可以通过 Beanshell 脚本 像:
图形界面模式
GUI mode
import org.apache.jmeter.gui.GuiPackage;
String scriptName = GuiPackage.getInstance().getTestPlanFile();
vars.put("scriptName", scriptName);
非图形用户界面模式
non-GUI mode
import org.apache.jmeter.services.FileServer;
String scriptName = FileServer.getFileServer().getScriptName();
vars.put("scriptName", scriptName);
将您选择的代码片段放入任何Beanshell"测试元素(采样器、前/后处理器或断言),它将获得 .jmx 测试脚本名称并将其存储到 ${scriptName}代码>变量.
Put the code snippet of your choice into any "Beanshell" test element (sampler, pre/post processor, or assertion), it will get .jmx test script name and store it into ${scriptName}
variable.
要了解有关 JMeter 中 Beanshell 脚本的更多信息,请查看 如何使用 BeanShell:JMeter 最喜欢的内置组件 指南.
To learn more about Beanshell scripting in JMeter check out How to use BeanShell: JMeter's favorite built-in component guide.
这篇关于如何在变量中获取 JMX Jmeter 文件名的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!