3
votes

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

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.

For example:

  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).

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.

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

2

2 Answers

4
votes

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

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

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

3
votes

Try to use __eval function instead:

/user/${__eval(${id})}/list/${__eval(${list})}

__eval function seems to be just your case.