访问 JMeter 脚本路径 [英] Access to JMeter script path

查看:17
本文介绍了访问 JMeter 脚本路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过变量/属性访问当前脚本的绝对物理路径?调试采样器似乎没有列出任何内容.

Is there a way of accessing the current script's absolute physical path via a variable/property? There doesn't appear to be anything listed via a Debug Sampler.

加载 CSV 文件和 JMX Includes 等操作使用当前工作目录作为其相对路径非常烦人.

It's incredibly annoying that actions like loading CSV files and JMX Includes uses the current working directory as its relative path.

推荐答案

  • 包含控制器
    根据组件的参考:

    • Include Controller
      As per component's reference:

      该元素不支持文件名中的变量/函数领域.
      但是,如果属性 includecontroller.prefix 是已定义,内容用于路径名的前缀. 如果文件在前缀+文件名给定的位置找不到,那么控制器尝试打开与 JMX 启动相关的文件名目录(JMeter 2.3.4 之后的版本).

      This element does not support variables/functions in the filename field.
      However, if the property includecontroller.prefix is defined, the contents are used to prefix the pathname. If the file cannot be found at the location given by prefix+filename, then the controller attempts to open the fileName relative to the JMX launch directory (versions of JMeter after 2.3.4).

      您可以向 JMeter 传递一个名为 includecontroller.prefix 的 java 属性可用于将目录添加到您所在的 JMX 文件包括.

      You can pass JMeter a java property named includecontroller.prefix which can be used to prepend a directory to the JMX file you're including.

      1) 在控制台启动的情况下使用:

      <代码>-Jincludecontroller.prefix=/full/path/to/jmx/scripts/dir/

      2) 在 GUI 的情况下 - 将相同的内容添加到 .sh/.cmd/.bat 文件或编写包装文件;
      3) 在 Jmeter Ant Task 使用的情况下 -设置为单独的属性:

      1) In case of console launch use:

      -Jincludecontroller.prefix=/full/path/to/jmx/scripts/dir/

      2) in case of GUI - add the same to .sh/.cmd/.bat file or write a wrapper file;
      3) in case of Jmeter Ant Task usage - set as separate property:

      <jmeter 
      jmeterhome="${jmeter.home}" 
      testplan="..." 
      resultlog="...">
          <property name="jmeter.save.saveservice.assertion_results" value="all"/>
          <property name="jmeter.save.saveservice.output_format" value="xml"/>
          <property name="includecontroller.prefix" value="..."/>
      </jmeter>
      

    • CSV 数据集配置
      根据组件的参考:

    • CSV Data Set Config
      As per component's reference:

      相对文件名是根据路径解析的主动测试计划.
      也支持绝对文件名,但请注意他们不太可能在远程模式下工作,除非远程服务器具有相同的目录结构. 如果相同的物理文件是以两种不同的方式引用 - 例如csvdata.txt 和 ./csvdata.txt - 然后将这些 > > 视为不同的文件.如果操作系统不区分上和小写,csvData.TXT 也会单独打开.

      Relative file names are resolved with respect to the path of the active test plan.
      Absolute file names are also supported, but note that they are unlikely to work in remote mode, unless the remote server has the same directory structure. If the same physical file is referenced in two different ways - e.g. csvdata.txt and ./csvdata.txt - then these are > > treated as different files. If the OS does not distinguish between upper and lower case, csvData.TXT would also be opened separately.


      您可以声明一个测试计划变量,该变量使用包含 csv 数据文件的文件夹检索参数值:
      例如


      You can declare a test plan variable that retrieves parameter value with the folder containing csv data files:
      e.g.

      csv.path | ${__P(csv.path, ${__property(user.dir)}${__BeanShell(File.separator,)})} 

      CSV Data Set Config
      Filename = ${csv.path}${__P(users-list,)}
      

      从控制台设置:

      -Jcsv.path=/full/path/to/csv/data/dir/

      分布式测试设置:

      -Gcsv.path=/full/path/to/csv/data/dir/

    • 这篇关于访问 JMeter 脚本路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆