Variables From CSV File since 0.2.1
This Config item allows you to load variable values from CSV file. Variable names and values taken from CSV file, name from first column, value from second column, respectively.
Tutorial
Let's create a text file c:\temp\testvariables.csv with following content:
First_Variable,here comes value 1
Second_Variable,and here value 2
Let's create test plan with Variables From CSV File, Thread Group, Debug Sampler and View Results Tree. Then configure Variables From CSV File, give it filename testvariables.csv, optional variable prefix MyVar_ and column separator ','. Now your plan should look like this:
Save this test plan to c:\temp\test1.jmx.
Now, run the test, go to View Results Tree and click on Debug Sampler, then click on Response data tab. You'll see that your variables from testvariables.csv are defined in JMeter, e.g.:
JMeterVariables:
MyVar_First_Variable=here comes value 1
MyVar_Second_Variable=and here value 2
JMeterThread.last_sample_ok=true
JMeterThread.pack=org.apache.jmeter.threads.SamplePackage@10cc9b4
START.HMS=153028
START.MS=1264671028968
START.YMD=20100128
TESTSTART.MS=1264671163750
Thanx a lot! One of most useful plugins!
It seems to override variables if several configs are added.
there seems to be a bug with this. I have a csv file with where I have defined my endpoint for my rest service var_server_name,api.foobar.com
I have a http testsetp, where the servername field is ${var_server_name}. I have quite a few of these teststeps thread groups in my test plan.
While running a simple test (about 5 thread groups, each with its own http step), I notice that some of them start failing with this error in the response
java.net.UnknownHostException?: ${var_server_name} the GET request looks like
GET http://${var_server_name}/....
so it seems like under a slight load, this feature does not work and the variables are not retrieved.
This works fine if I use the 'user defined variables'
Ali
Ali, I tried to reproduce your issue, for me everything works well. Maybe you have scope problems. Could you send me your test plan to look at it? Or at least tree screenshot.
i need a documentation about jmter and the variables plz :)
Hi there i have similar issue with csv variables. It seems that there can only be one csv variables instance. I wanted to add two csv config elements in the root of the test plan. First one would have default settings (for example default endpoint to the service). Below i wanted to have evnironment dependant csv. I would pass the name of the environment in command line so i would use default.csv and then override some of the variables with test.csv or staging.csv.
Is there way to make it work? is it a scoping issue or is the component a singleton or is there some bug? Variables that are in the second file (for example staging.csv) are available but all the other varialbes that were defined in default.csv are not available. If i load default.csv only then they are back. So it feels like there can only be one variables from csv at the time is that right?
Art
It is expected for multiple config items to work correct. This may be a bug, could you raise it at Issues section?
Guys, I need some help, this really works gorgeous when everything is hardcoded, I tried to add the Variables From CSV File and everything works fine following your example.
Now, the problem:
After running the test plan I got: 15:40:44 - ERROR: Unknown host exception occured. Please verify access to the server '${server1}'. (required for CPU)
Problem: Variables are not resolved in the PerfMon Metrics Collector, therefore I can't use variables from the CSV FILE.
But, if I use "user defined variables" I can see the correct values.
A second problem, if I use no gui mode "user defined variables" doesn't work and I have to use ${P(server1)} instead of ${server}and pass the variable in the command line like java -Jserver1=localhost, so, there is some inconsistency treating the variables.
Do you guys have any ideas or suggestions?
Could you use Issues tab instead of comments for such complex case? Attach reproducing test plan to issue, please
The new "Variables From CSV File" will work with perfmon.