0
votes

I understand that the CSV Data Set Config cannot use JMeter Variable as the "Filename", so I used the __property function as suggested in different posts:

  • I defined an initial variable (datapoolpath) in the "User Defined Variable" config element
  • I then converted my 'datapoolpath' variable in a property 'pdatapoolpath' in a BeanShell PreProcessor
  • I used the ${__P(pdatapoolpath)} in the Filename field for the CSV Data Set Config

This workaround runs fine when I run the mytest with the Jmeter GUI. As soon as I try to run the same test via cli (jmeter -n -t mytest,jmx -Jdatapool=c:\datapool), then it doesn't work anymore (ie: the csv data config is not able to find the csv file, since the property "pdatapoolpath" value is null. Please note, that in my BeanShell script I use to print the property's value, and still it seems to be correctly printed.

So my question is: where am I wrong? why jmeter behaves differently when run from GUI vs CLI?

thanks in advance

1

1 Answers

1
votes

You can use variables in the CSV Data Set Config field If it can get initialized in the UDV.


Assuming there is a file in the name and in the path c:\datapool.csv, by using -J - you are actually passing a property to the JMeter test ; not variable.

-J, --jmeterproperty {argument}={value}
            Define additional JMeter properties

If you invoke like this

jmeter -n -t mytest.jmx -Jdatapool=c:\datapool.csv

You can directly use this in the CSV Data Set Config by using the property name passed in the commandline.

${__P(datapool)}

If you need to copy this property to a User Defined Variable,

vdatapool = ${__P(datapool)}

then access the variables as given below in the CSV data set config.

${vdatapool}

This is how we need to access variables and properties in JMeter.

${variablename}

${__P(proprtyname)}