Variables From CSV FileThis 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. In the CSV File: window, you can specify the absolute path to your csv file. However, to make your test plans more portable, you can also use dynamic path by evaluating ${} expressions. TutorialLet's create a text file c:\temp\testvariables.csv with following content: First_Variable,here comes value 1 Second_Variable,and here value 2 1. To use the absolute path, let's create test plan with Variables From CSV File, Thread Group, Debug Sampler and View Results Tree. Then configure Variables From CSV File, specify the absolute path to 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 2. To use dynamic path you should specify expressions enclosed in ${}, e.g.: ${__groovy(import org.apache.jmeter.services.FileServer; FileServer.getFileServer().getBaseDir();,)}${__groovy(File.separator;,)}resources${__groovy(File.separator;,)}properties.csvThis expression dynamically resolves the path (like D:\JAVApetprojects\resources\properties.csv) relative to the directory of the current .jmx file. |
|