1
votes

I am using jmeter to test our system using the 'HTTP Request' sampler. Some of the values in the request are parameterized using a csv file using 'CSV Data Set Config'.

There are 600 rows in the csv file with one row used for one http request so I have Loop Count set to 600. Each row is in effect one test case. I only need one thread. So in my result tree I see 600 result entries when run - this is all working fine.

I am now trying to say just execute rows 10 to 15 only in the csv i.e. test cases 10 to 15 instead of all 600. I have tried to get something like this working mostly through the use of Controllers but I am missing something.

Could anybody point me in the right direction on this please ? Thanks in advance - Ian.

2

2 Answers

0
votes

Add a counter before your request with the below configurations:

  • Start: 1
  • Increment: 1
  • Reference Name: Counter

Then put your request inside an If controller with this condition ${__javaScript("${Counter}" > 9 && "${Counter}" < 16)}

This will make your script execute only rows from 10 to 15.

-1
votes

I believe the fastest and the easiest solution would be generating a brand new CSV file containing only necessary rows before your test like:

  1. Add setUp Thread Group to your Test Plan
  2. Add Test Action Sampler to the setUp Thread Group (you don't need an extra result, don't you?)
  3. Add JSR223 PreProcessor as a child of the Test Action Sampler
  4. Put the following code into "Script" area:

    new File('/path/to/original.csv').readLines()[9..14].each {line ->
        new File('/path/to/new.csv') << line << System.getProperty('line.separator')
    }
    
  5. Amend your test to use new.csv instead of the original.csv

Of course change /path/to/original.csv to real path of the "source" CSV file with 600 entries, the same for the new.csv. The paths can be either absolute or relative.

See Apache Groovy - Why and How You Should Use It article for more information on Groovy scripting in JMeter tests.