Jmeter 在用户定义变量中设置相对于 Jmeter 安装的相对路径
Jmeter Set Relative Path Relative to Jmeter Install in User Defined Variables
我想知道是否有一种方法可以在测试计划的“用户定义变量”中引用与 Jmeter 安装相关的文件?例如,而不是使用名为 'sampleFile' 的变量和它的值:C:\Jmeter\apache-jmeter-3.2\bin\example.txt 我想要一个名为 'sampleFile' 的变量,它的值是相对于安装的,所以:..\bin\example.txt 或..\lib\example.txt.我问这个是因为我想把脚本放在服务器上。
长话短说:我可以创建相对于 Jmeter 安装的路径吗?如果是这样怎么办?谢谢!
有效。
${__javaScript(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir())}/js/script.js
您可以使用 __P() function 引用它,例如:
${__P(user.dir,)}
参见:
- Apache JMeter Functions - An Introduction 熟悉 JMeter 函数概念
- Functions and Variables JMeter 用户手册章节
- Java System Properties看看你还能用这种方式做什么
我想知道是否有一种方法可以在测试计划的“用户定义变量”中引用与 Jmeter 安装相关的文件?例如,而不是使用名为 'sampleFile' 的变量和它的值:C:\Jmeter\apache-jmeter-3.2\bin\example.txt 我想要一个名为 'sampleFile' 的变量,它的值是相对于安装的,所以:..\bin\example.txt 或..\lib\example.txt.我问这个是因为我想把脚本放在服务器上。
长话短说:我可以创建相对于 Jmeter 安装的路径吗?如果是这样怎么办?谢谢!
有效。
${__javaScript(org.apache.jmeter.services.FileServer.getFileServer().getBaseDir())}/js/script.js
您可以使用 __P() function 引用它,例如:
${__P(user.dir,)}
参见:
- Apache JMeter Functions - An Introduction 熟悉 JMeter 函数概念
- Functions and Variables JMeter 用户手册章节
- Java System Properties看看你还能用这种方式做什么