this is my objective:
keep the Test Plan more flexible and usable both on win and mac (since some people use mac and other use win).
I created this simple script in groovy:
import org.apache.jmeter.services.FileServer;
import groovy.json.JsonSlurper;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
String winPath;
String macPath;
String winSlash;
String macSlash;
String userPath;
String userSlash;
if (System.properties['os.name'].toLowerCase().contains('windows')) {
winPath="C:\\QA\\";
winSlash="\\";
vars.put("userPath",winPath.toString());
}
if (System.properties['os.name'].toLowerCase().contains('mac')) {
macPath="/Users/macUser/QA/";
macSlash="/";
vars.put("userPath",macPath.toString());
}
and add it into a "JSR223 Sampler" object under my Thread Group object
Then I've added a "User Defined Variables" object with the following var:
Name value
projectDir myProjectDir
rootPath ${__groovy(props.getProperty("userPath"))}${projectDir}
Then I tried to used the rootPath variable for setting the path of my csv files, so I've added ${projectDir}/AUTH.csv
to FileName
in "CSV Data Set Config" object, but I got this message:
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Ignoring property 'property' in org.apache.jmeter.config.CSVDataSet
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestBeanHelper: Setting filename=myProjectPath/AUTH.csv
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 2
2018-11-23 16:36:40,634 DEBUG o.a.j.t.TestCompiler: Subtracting node, stack size = 1
2018-11-23 16:36:40,634 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2018-11-23 16:36:40,634 INFO o.a.j.s.FileServer: Stored: myProjectPath/AUTH.csv
2018-11-23 16:36:40,635 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.IllegalArgumentException: Could not read file header line for file myProjectPath/AUTH.csv
as you can see it trying to read myProjectPath/AUTH.csv
and then off course it get an exception..
why it doesn't "read" the variable rootPath ?
any suggestions?