What is Parameterization
It is the way of replacing a hard coded value in the script with a parameter which represents a list of values. It is a script that contains the actual values used during recording and during script enhancement phase test engineer has to replace the recorded values with parameters is known as parameterizing the script.Why Parameterize
- It allows you to test your script with different values
- Replace the constant values in Script with parameters
- simulate real user behavior while running the test
Identifying the test data on AUT
For successful performance test, Performance test environment should be exact replica of production environment. So test data should be identified and then it should be used while execution. Building the accurate test data very similar to production environment is the fundamental step for successful performance test.To check what could be test data in your application, just watch each http request. Under http request there could be parameter and there values. So, this is particular parameter for which test data should collect. Some of examples are listed below:
- While login “Username” & “Password” are parameter for which test data needed.
- While registration “First Name”, “City” etc is parameter for which test data needed.
Using the CSV Data Config in Jmeter Tests
Using Parameterization we can execute one test plan for more than one user at the same time. This is a method of generalizing an action for many users.
To Parameterize Jmeter please follow the steps give below:
1. Open MS file and type the words
csv file for parameterization
|
2. Save page on desktop as login.csv
3. Follow the process and record the script for login for a single word in Jmeter. Why I am suggesting single word because later we are going to parameterize other words.
Once the script will be recorded the page will look like.
Script
|
4. Now Click on the thread name login1 and change “USERNAME” and “PASSWORD” parameters as ${username}and ${password}. ‘username’ and ‘password’ we are going to use as a Variable to store different parameters for the login.
Before Replacement
|
After Replacement
|
5. Now right click on the thread search and add CSV Data Set Config:
Right Click on search thread–> Add–> Config Element–> CSV Data Set Config
Once CSV Data Set Config page is added we need to configure-
Filename: This is the name of the file where you are going to save the different search words. (Don’t worry I will make you easy to understand in next few steps.)
Variable Names: This is the name of the variable where we will store the search data during running the script.
Stop thread on EOF: Once search will be completed the thread will get stopped automatically.
So now I am going to configure these fields-
Filename: login.csv
Variable Names: username, password
Stop thread on EOF: False
csv set data config
|
6. Click on Thread Group and change Number of Threads as 2 and Ramp-Up Period as 1. I am suggesting to make it 2 because we are going to login 2 key words. Or you can say we are going to user 2 users to search each keyword.
Thread Group for Parameterization
|