Vijay Rathod
Vijay Rathod

Reputation: 35

How to pass variable as file name to jmeter CSV Data set Config?

I am using multiple csv files in one thread for comparision purpose.

Here first CSV Data set Config returns the file names

1.csv
5.csv
1000.csv

now I want to pass above file name to second CSV Data set Config C:\\Softwares\\Installed\\jmeter-3.0\\bin\\TestData\\files\\${filename}

Is it possible in jmeter? can any one help me to resolve the problem.

Thanks, Vijay

Upvotes: 3

Views: 7952

Answers (1)

Dmitri T
Dmitri T

Reputation: 168002

CSV Data Set Config is getting initialized before any JMeter Variable therefore your ${filename} will never be resolved and you will be getting "File not found" errors.

The options are in:

  1. Consider using __CSVRead() function instead of CSV Data Set Config
  2. Switch to JMeter Properties instead of JMeter Variables.

    • Change ${filename} to ${__P(filename)} (see __P() function documentation for syntax)
    • Define filename property. It can be done in 2 ways:

      • Via user.properties file. Add the next line to the file:

        filename=C:\\Softwares\\Installed\\jmeter-3.0\\bin\\TestData\\files\\1.csv
        

        JMeter restart will be required to pick up the property

      • Via -J command-line argument:

        jmeter -Jfilename=C:\Softwares\Installed\jmeter-3.0\bin\TestData\files\1.csv
        

      See Apache JMeter Properties Customization Guide for more information on JMeter properties and ways of setting, getting and overriding them

Upvotes: 13

Related Questions