0
votes

Good day, everyone!

My goal is to make each thread user to use their own .csv file and take a different value from it each loop.

What I have is:

  • A CSV Data Set Config element with path to .csv file I use to log in users (specified USER variable in CSV Data Set Config for this purpose, no password for now) containing a user1 and user2 values.
  • Two one-column .csv files named user1 and user2 respectively to the names of users who use them.
  • Each of this file contains a column with values user1(or user2 respectively to a file name)_test1, user1_test2 and so on.

My test looks like:

  • Login
  • HTTP GET request with variable from specific user's csv file (like http://google.com.${__CSVRead(path\to\file.csv,0)} )

My first failure was to use same variable I use to log in a specific user as I use in CSV Data Set Config, e. g. http://google.com.${__CSVRead(path\to\${USER}.csv,0)}. But instead of sending http://google.com.user1_test1 request, jmeter sends just http://google.com. I checked USER variable outside CSVRead function and it worked fine, so I have no idea what I did wrong in passing it to function.

When I used a static path to .csv in my request ( http://google.com.${__CSVRead(path\to\file\user1.csv,0)} ) I found that each user1 loop uses the first variable from user1.csv each time and all user2 loops use only second variable.

When I do something like:

http://google.com.${__CSVRead(path\to\file\user1.csv,0)}${__CSVRead(path\to\file\user1.csv,next)} I get:

http://google.com.user1_test2, http://google.com.user1_test4, and so on (close, but not enough ;), so may be I use "next" the wrong way)

So my questions are:

  • Is there a way to pass variable to CSVReader file path?
  • Is there a way to to make Jmeter to iterate through a .csv file with CSVRead function each loop instead of each thread?

Thanks for reading, I hope someone can help.

1
I've managed to complete my task by just putting required test data to a single .csv file and accessing it directly via __StringFromFile, each loop in each thread gets a different data value. It was not relevant which user will use that specific data value, so it is enough to me for now. But i'm still curious about questions I asked at first place - Yevhen Tokarenko

1 Answers

0
votes

If you looked at functions manual it can be an escaping issue

When using \ before a variable for a windows path for example C:\test\${test}, ensure you escape the \ otherwise JMeter will not interpret the variable, example: C:\test\${test}.

So you need to change to ${__CSVRead(path\to\${USER}.csv,0)}

But answering your second question, I suggest you use CSV Data Set Config instead as suggested in __CSVRead:

In most cases, the newer CSV Data Set Config element is easier to use.

CSV Data Set Config can iterate lines in a loop easier and with more options to control its flow.

If you want each thread to have its own set of values, then you will need to create a set of files, one for each thread. For example test1.csv, test2.csv, …, testn.csv. Use the filename test${__threadNum}.csv and set the "Sharing mode" to "Current thread".