Get Knowledge from Video instead of Content:

Tuesday 4 October 2016

JMeter - Same CSV Data value in Each Iteration


The content has been moved to PerfMatrix.

Link: https://www.perfmatrix.com/same-parameter-value-in-each-iteration-in-jmeter/


6 comments :

  1. Can you please explain detail how this code working?

    ReplyDelete
  2. Hi Gagandeep, could you please elaborate this code

    ReplyDelete
    Replies
    1. Part 1:

      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

      Delete
  3. 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.

    ReplyDelete
    Replies
    1. Please try to put .csv file in bin folder of apache-jmeter.

      Delete