I am new to JMeter, so please bare with me. Let's say I have a performance test with 100 v-users and I want to have at least 20 items in the cart / user. How can i control this in JMeter and where?
You have at least 3 options, depending on what exactly you're trying to achieve:
- Thread Group - Loop Count - defines the number of iterations for each virtual user (affects all nested samplers)
- Loop Controller - basically the same as above, but you can limit iterations to only those samplers which are required
- Throughput Controller - controls how many times (in absolute number values or percentages) children samplers are executed. See Running JMeter Samplers with Defined Percentage Probability article for more detailed explanation of the Throughput Controller and the Switch Controller
To check 100 users login and each user need to have 20 items in their cart, you need to create a flow with Data Driven execution. Preferable way is to create a excel/csv file and save all the 100 username and password in it.
- Create HTTP request for Login API:- Fetch the first username & password and perform login.
- Create HTTP request for Cart API: In the body, include all 20 items you want to have in that user`s Cart(If you dont want each user to have same items in Cart then create another excel/csv file containing several cart Items)
Put HTTP1 and HTTP2 in a for loop where condition will be end of the line or 100(whichever suites you)