Hard-coding test data in JMeter scripts leads to brittle plans that are difficult to reuse across environments or scenarios. Parameterisation with variables, CSV data and correlation makes your tests more flexible and realistic.
Using Variables, CSV Data and Correlation
JMeter lets you define user variables and read values from CSV files so each thread can use different inputs, such as user credentials or product IDs. Correlation refers to capturing values from one response (like session IDs or tokens) and reusing them in subsequent requests.
Example techniques:
- CSV Data Set Config: reads usernames/passwords from a file
- User Defined Variables: store base URLs or common parameters
- Regular Expression Extractor: capture a token from a response
- JMeter functions: ${__Random(1,1000)} for random numbers
With parameterisation and correlation in place, each virtual user behaves more like a real user rather than repeating the same static sequence.
Common Mistakes
Mistake 1 โ Using the same credentials and IDs for all threads
This creates unrealistic contention.
โ Wrong: Every thread logging in as the same user and updating the same records.
โ Correct: Use CSV or factories so threads represent distinct users or sessions where appropriate.
Mistake 2 โ Ignoring dynamic values like tokens
This breaks flows.
โ Wrong: Hard-coding tokens or assuming they never change.
โ Correct: Extract dynamic values from responses and feed them into later requests.