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

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

问题描述

是否可以通过变量/属性访问当前脚本的绝对物理路径?似乎没有通过Debug Sampler列出任何内容.

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启动的fileName 目录(2.3.4之后的JMeter版本).

      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蚂蚁任务的使用-设置为单独的属性:

      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/

      用于分布式测试设置的设置:

      Setting for distributed testing setup:

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

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

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