是否可以在从CSV获得的值中包含jmeter变量? [英] Is it possible to include jmeter variables in values obtained from CSV?

查看:179
本文介绍了是否可以在从CSV获得的值中包含jmeter变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个csv文件,其中包含一个名为查询"的列.我要查询的全部内容之一是/user/${id}/list/${list}.

I have a csv file which contains a column named "query". One of the entires I have for query is /user/${id}/list/${list}.

我想做的是,当jMeter传递给HTTP Sampler时,它会使用测试计划中先前步骤中已使用的变量值,让jMeter覆盖查询中的$ {list}和$ {id}变量.

What I would like to do is let jMeter overwrite the ${list} and ${id} variables in the query when it is passed to a HTTP Sampler with variable values already in use from previous steps in my test plan.

例如:

  1. 在测试计划中,创建$ {id} = 5和$ {list} = 10.
  2. 在测试计划中,打开包含查询字符串的csv文件.
  3. 在测试计划中,使用HTTP Sampler执行.查询中的路径应该是从csv文件传递的查询值. 3a. Jmeter应该接受传递给采样器的查询,并将$ {id}和$ {list}替换为存储在测试计划(5和10)中这些变量的值.
  1. In test plan, create ${id} = 5 and ${list} = 10.
  2. In test plan, open csv file that contains query string.
  3. In test plan, perform use a HTTP Sampler. Path in query should be the query value passed from csv file. 3a. Jmeter should take query passed to sampler and replace ${id} and ${list} with the values stored to those variables within test plan (5 and 10).

现在,当我尝试此操作时,HTTP响应又回来了,显示请求是针对/user/${id}/list/${list}而不是/user/5/list/10的.

Right now when I try this, the HTTP response comes back showing the request was made to /user/${id}/list/${list}, not /user/5/list/10.

有人知道如何通过jMeter强制替换吗? 甚至有可能吗?

Does anyone know how to force the substitution through jMeter? Is it even possible?

推荐答案

经过一番头部抓挠,我得以弄清这一点.

I was able to figure this one out after a bit of head scratching.

JMeter允许您通过使用__eval函数来重载变量(在变量中放置对变量的引用).

JMeter allows you to overload variables (place references to variables within a variable) by using the __eval function.

要解决此问题,我按原样保留了csv文件,并引用了变量集.当我想从csv文件引用查询并使用实际值重载变量占位符时,我使用了$ {__ eval($ {query})}-其中query =

To get around the issue, I left the csv file as is, with references to variables set. When I wanted to reference the query from the csv file and overload the variable placeholders with actual values I used ${__eval(${query})} - where query = the

这篇关于是否可以在从CSV获得的值中包含jmeter变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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