CSV Data Set Config
We cannot define a large data set in JMeter script and it is also not recommended to generate large set of random values at run-time as it is expensive in terms of CPU and memory. So we can create test data in advance and can be used as run-time parameter to create different sets of values from each run. Loading data from a file at run-time is cheaper than generating it. To Load data from a file 'CSV Data Set Config' is used in JMeter. 'CSV Data Set Config' is used to read lines from data file. Data is split according to the delimiter and assigned into variables. JMeter supports CSV files. CSV files which have a header line as the column names followed by data with new line. By using 'CSV Data Set Config' we can answer below questions.
How to load data from external data sources using JMeter
How to simulate load with concurrent unique logins using JMeter or Multiple User Login in JMeter
How to simulate load with concurrent unique logins using JMeter or Multiple User Login in JMeter
Multiple User Login Example:
In this example we will load data from external data source and achieve Multiple User Login in JMeter. We will- Simulate a load test with 5 concurrent unique Login.
- Username and password will be loaded from Data file.
To do so please follow the below steps:
- Create a test plan.
- Test Plan contains one Thread Group.
- Thread Group contains:
- “CSV Data Set Config”
- “HTTP Request”.
- “View Results Tree”
To step above Test Plan and HTTP request, please refer post: First HTTP request in JMeter | Running first JMeter Test
How to add CSV Data Set Config
- Right-click on the Thread Group,
- Select Add menu > Config Element > then select CSV Data Set.
CSV Data Set Config Settings:
Filename: Enter the file name only if file is present inside /bin directory else enter the complete path of file.
Variable Names(comma-delimited) : Enter the column names from the file. If headers are not present in the file then the entered variables are interpreted as the column names. JMeter supports CSV header lines: if the variable name field empty, then the first line of the file is read and interpreted as the list of column names.
Data File Configuration:
Data file contains Username and password for script as shown in figure below. Data file is stored in /bin directory and named as credentials.txtThread Group Configuration:
Define number of thread for test execution and duration. In this example we have setNo. of threads: 5
Ramp-up period: 1
Loop count : 1