Search code examples
jmeterparameterization

Running an existing JMeter Test with parametrization using csv file from Java code


I have recorded the jmeter script with CSVDataConfig. I mentioned the csv config file location as "search.csv" like

 <CSVDataSet guiclass="TestBeanGUI" testclass="CSVDataSet" testname="CSV Data Set Config" enabled="true">
            <stringProp name="delimiter">,</stringProp>
            <stringProp name="fileEncoding"></stringProp>
            <stringProp name="filename">search.csv</stringProp>
            <boolProp name="quotedData">false</boolProp>
            <boolProp name="recycle">true</boolProp>
            <stringProp name="shareMode">shareMode.all</stringProp>
            <boolProp name="stopThread">true</boolProp>
            <stringProp name="variableNames">searchkeyword</stringProp></CSVDataSet>

Now I call the jmeter non gui using the following code in java as

public  String sJMeterHome              = "C:/Apache/apache-jmeter-2.13";
public  String sJMeterProprtiesPath     = "C:/Apache/apache-jmeter-2.13/bin/jmeter.properties";
String sUrlTestScriptFilePath = "C:/SourceFiles";
FileInputStream oFileTestCaseNameCSV = new FileInputStream(sUrlTestScriptCSVFilePath);
JMeterUtils.setJMeterHome(sJMeterHome);
JMeterUtils.loadJMeterProperties(sJMeterProprties.getPath());
JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
JMeterUtils.initLocale();
StandardJMeterEngine jmeter = new StandardJMeterEngine();
HashTree testPlanTree = new HashTree();
SaveService.loadProperties();
testPlanTree = SaveService.loadTree(oFileTestCaseName);
jmeter.configure(testPlanTree);
jmeter.run();

Now the problem is csv file not found exception error thrown.

I store the jmx and csv file in same folder. oFileTestCaseName - is read the jmx file and add in saveservice.

How can I resolve this issue


Solution

  • Did you mention the full CSV file name i.e C:/SourceFiles/filename.csv ?