Use same row per thread from a CSV data set in JMe

2019-07-18 03:14发布

I want to make a test plan in JMeter as follows:

I have a specific flow with a web server:

Req1  
Reply for Req1  
Req2  
Reply for Req2  
Req2  
Reply for Req2    
etc

I need to have these run as a single flow i.e. each thread executes this from start to finish (not Req1 and Req2 send by different threads).
I also need to send different parameters in each iteration so I used CSV data set.

Problem:
I need to send the same row from CSV for all the requests per thread.

For example:
If I have the following CSV:

john,A1111,engineer  
bill,A2111,manager  
mary,C1111,secretary   

I need the first row to be send in all the flow from Req1 to the last request by thread 1 and the second row by thread 2 in all requests etc.

Is this possible? I tried adding the same CSV file to all my controllers but still does not work as expected.

Update:
What I am interested in is having each thread consume 1 row from the CSV file and "cache" that row for all requests in my flow.

1条回答
我只想做你的唯一
2楼-- · 2019-07-18 03:26

The simplest way to implement your scenario is like the following:

Test Group
Number of Threads = N
    CSV Data Set Config
    Filename: ... (your csv-file here)
    Variable Names: name,id,position       // (as per your csv sample above)
    Delimiter: ,
    Recycle on EOF = True
    Stop Thread on EOF = False
    Sharing Mode = All threads
    Simple Controller  // that's optional: simply to group your requests flow
        Sampler 01     // use ${name}, ${id}, ${position} variables to refer extracted values
        Sampler 02
        ...
        Sampler X
  • Number of Threads = N will start N threads;
  • Sharing Mode = All threads or Sharing Mode = Current thread group will enforce each thread to read separate row from csv and then use extracted values in all the subsequent samplers;
  • Recycle on EOF = True will recycle your csv if number of threads N > number of entries in csv.
查看更多
登录 后发表回答