How to parameterize in JMeter?
There are various methods for parameterization in JMeter, one commonly used method is as follows:
- Open JMeter and create a test plan.
- Right-click on the test plan, then select “Add -> Thread Group”.
- Right-click on the Thread Group, select “Add -> Config Element -> CSV Data Set Config” option.
- Select a CSV file that contains data to parameterize. The format of the CSV file should have one parameter value per row, with each column corresponding to a parameter.
- Variable Names: Set one or more variable names to store parameter values from the CSV file. Multiple variable names can be separated by commas.
- Default separator between parameter values is a comma.
- Recycle on EOF: If the parameter values in the CSV file are all used up, should we start using the values from the first row again?
- Should all threads in the thread group be stopped if the parameter values in the CSV file are exhausted?
- Add requests that need to be parameterized, such as HTTP requests, to the test plan.
- ${variable name}
- your username
- When running the test plan, JMeter will send requests sequentially based on the parameter values in the CSV file, enabling parameterization.
Please take note:
- The path of the CSV file can be either a relative path or an absolute path. It is recommended to place the CSV file in the same directory as the test plan file when using a relative path.
- The parameter values in a CSV file can contain special characters, such as commas and quotes. If a parameter value contains a delimiter, you can use quotes to enclose it.
- Multiple CSV data files can be used to parameterize multiple parameters in a component, with each CSV data file corresponding to one parameter.
- If different parameter values are needed for each thread, the CSV file configuration element can be placed in a Loop Controller under the Thread Group, such as a Loop Controller or Random Controller.