-
Notifications
You must be signed in to change notification settings - Fork 0
Creating a Load Test Plan
Steps highlighted below consist of generally used modules of Jmeter for Testcases Creation. Each Testcase created is developed using different combinations of these modules as per the required logic.
TestCases Created for API are created using Jmeter GUI . Any Changes in Testcases are recommended to be done using JMeter GUI
Step 1: Open JMeter
- Navigate to the bin directory and run jmeter.bat (Windows) or jmeter.sh (Linux/Mac).
- Or run jmeter in terminal if environment variables are set.
Step 2: Add a Thread Group
Right-click on Test Plan > Add > Threads (Users) > Thread Group.
Configure the Thread Group:
- Number of Threads (users): Define the number of users to simulate.
- Ramp-Up Period (seconds): Time to start all users.
- Loop Count: Number of times to execute the test.
Thread Group
The Thread Group is the starting point for any JMeter test plan. It defines the number of threads (users) that will be simulated, the ramp-up period over which the threads will start, and the number of times the test will loop. It acts as a container for samplers, logic controllers, and other test elements. Proper configuration of the Thread Group is crucial to accurately simulate the desired load on the API.
Step 3: Add an HTTP Request Sampler
Right-click on Thread Group > Add > Sampler > HTTP Request.
Configure the HTTP Request:
- Server Name or IP: The API server address.
- Path: The endpoint path.
- Method: GET, POST, PUT, etc.
- Parameters: Add any necessary parameters for the request (form values).
HTTP Request as Sampler
The HTTP Request sampler is used to send HTTP/HTTPS requests to a web server. It is a crucial component in JMeter for simulating a user's request to an API endpoint. The sampler allows you to specify the URL, request method (GET, POST, PUT, DELETE, etc.), and any necessary parameters or body data.
Step 4: Add a Boundary Extractor
Right-click on HTTP Request > Add > Post Processors > Boundary Extractor.
Configure the Boundary Extractor:
- Name: The name for the extracted variable.
- Left Boundary: The text or pattern to the left of the desired data.
- Right Boundary: The text or pattern to the right of the desired data.
- Match No.: Which occurrence to extract (default is 1).
Boundary Extractor
The Boundary Extractor is a post-processor used to extract specific values from a response based on text boundaries. This is useful when you want to capture values that are between known start and end text patterns in the response data. In Faveo, we use the Boundary Extractor to get the cookie name and value.
Step 5: Add a JSON Extractor (If Needed)
Right-click on HTTP Request > Add > Post Processors > JSON Extractor.
Configure the JSON Extractor:
- JSON Path Expressions: Define expressions to extract data from the JSON response.
- Reference Names: Variables to store extracted data.
JSON Extractor
The JSON Extractor is a post-processor used to extract specific values from a JSON response using JSONPath expressions. This is useful for dynamically handling data returned by the server, such as tokens or IDs, which can be used in subsequent requests. In Faveo, we use the JSON Extractor to extract data from the response.
Step 6: Add a CSV Dataset Config
Right-click on Thread Group > Add > Config Element > CSV Data Set Config.
Configure the CSV Data Set Config:
- Filename: /path/to/your/csvfile.csv
- Variable Names: variable1,variable2,...
- Delimiter: ,
- Recycle on EOF: True/False
- Stop thread on EOF: True/False
- Sharing mode: All threads/Current thread group
CSV Dataset Config
The CSV Data Set Config element allows you to read data from a CSV file and use it in your test plan. This is useful for parameterizing your tests, such as sending different inputs for each simulated user or request iteration.
Step 7: Add an HTTP Cookie Manager
- Right-click on Thread Group > Add > Config Element > HTTP Cookie Manager.
- This manager stores and sends cookies across multiple requests.
HTTP Cookie Manager
The HTTP Cookie Manager stores and manages cookies during the test. It automatically handles cookies similar to how a web browser does, making it essential for maintaining session information between requests. Cookies are also used for authentication purposes in the testing environment.
JMeter Uses ${variable} to access the variable created in different modules this above case cookievalue , cookiename are two variables created in Boundary Extractor module
Step 8: Add Listeners
- Right-click on Thread Group > Add > Listener > View Results Tree.
- Right-click on Thread Group > Add > Listener > Summary Report.
Listeners
Listeners are components that collect and display results of the test execution.
View Results Tree:
This listener shows detailed results of each request, including request and response data. It is useful for debugging and verifying that the test is running correctly.
Summary Report:
This listener provides aggregate statistics of the test results, such as the number of requests, average response time, min/max response times, and throughput. It is useful for analyzing the overall performance of the API.
HTTP Header Manager
In Faveo, we use the HTTP Header Manager when there is a need to add headers for the APIs under HTTP Request. The HTTP Header Manager lets you add or override HTTP request headers, such as Content-Type, Authorization, or custom headers. This is essential for sending the correct metadata required by the server.