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

查看:23
本文介绍了是否可以在从 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 覆盖查询中的 ${list} 和 ${id} 变量,当它被传递到 HTTP 采样器时,变量值已经在我的测试计划的前面步骤中使用.

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 采样器.查询中的路径应该是从 csv 文件传递​​的查询值.3a.Jmeter 应该接受传递给采样器的查询,并将 ${id} 和 ${list} 替换为存储到测试计划(5 和 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})} - where query = the

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天全站免登陆