问题
I have a scenario to use data from each row for validation using a HTTP Request. have tried with the CSV config but it reads the first row only for the iteration. I have a single iteration and all my samplers are in a single thread group. The data from csv file is retrieved sequentially only when i give the iterations to a value say 3 (each iteration each row is taken)
How to achieve on reading the csv file rows sequentially for single iteration ,where the thread group contains many HTTP request and i need the value from each row for each requests.
Kindly suggest me a solution
回答1:
As per CSV Data Set Config documentation:
By default, the file is only opened once, and each thread will use a different line from the file. However the order in which lines are passed to threads depends on the order in which they execute, which may vary between iterations. Lines are read at the start of each test iteration. The file name and mode are resolved in the first iteration.
So implementing your scenario using CSV Data Set Config doesn't seem to be possible, I would recommend considering using JMeter functions instead such as:
- __StringFromFile()
- __CSVRead()
These functions read next line from the file each time they're called so you can use them instead of CSV Data Set config in each of the HTTP Request samplers. Check out Apache JMeter Functions - An Introduction to get familiarized with JMeter Functions concept.
来源:https://stackoverflow.com/questions/48583619/read-excel-data-csv-file-sequentially-in-jmeter