import org.apache.commons.io.FileUtils; //Importing the related package List lines = FileUtils.readLines(new File("test.csv")); // Created an object of type List and pass the reference of .csv file bsh.shared.lines = lines; // Pass the object value
Part 2: int user = ctx.getThreadNum(); //Get Total number of thread count String line = bsh.shared.lines.get(user); //Create a new variable of type String String[] tokens = line.split(","); // Create an array of type String to separate out the data in a single line vars.put("ID", tokens[0]); // Pass the value in Parameter vars.put("pass", tokens[1]); // Pass the value in Parameter vars.put("item", tokens[2]); // Pass the value in Parameter vars.put("product", tokens[3]); // Pass the value in Parameter
Hi Gagandeep.. passing .csv file fails whereas giving the path of the file location works. Can you suggest me how did you pass the file name directly, that's what i am looking for and it doesn't seem to work.
Can you please explain detail how this code working?
ReplyDeleteDo you want me to explain the code steps?
DeleteHi Gagandeep, could you please elaborate this code
ReplyDeletePart 1:
Deleteimport org.apache.commons.io.FileUtils; //Importing the related package
List lines = FileUtils.readLines(new File("test.csv")); // Created an object of type List and pass the reference of .csv file
bsh.shared.lines = lines; // Pass the object value
Part 2:
int user = ctx.getThreadNum(); //Get Total number of thread count
String line = bsh.shared.lines.get(user); //Create a new variable of type String
String[] tokens = line.split(","); // Create an array of type String to separate out the data in a single line
vars.put("ID", tokens[0]); // Pass the value in Parameter
vars.put("pass", tokens[1]); // Pass the value in Parameter
vars.put("item", tokens[2]); // Pass the value in Parameter
vars.put("product", tokens[3]); // Pass the value in Parameter
Hi Gagandeep.. passing .csv file fails whereas giving the path of the file location works. Can you suggest me how did you pass the file name directly, that's what i am looking for and it doesn't seem to work.
ReplyDeletePlease try to put .csv file in bin folder of apache-jmeter.
Delete