1. Introduction
Test recording in JMeter helps automate the creation of load test scripts by capturing actual HTTP requests from a web application. This method is beneficial for creating realistic test scenarios based on real user interactions.This report details the process of creating a load test script using test recording, running the test in both GUI and non-GUI modes, and executing load tests with different user loads.
2. Prerequisites
Before you start, ensure you have:
Java Development Kit (JDK): JMeter requires Java. Ensure JDK is installed on your system.
JMeter Installation: Download and install JMeter from the Apache JMeter website.
Browser Configuration: The process involves configuring a proxy in your browser to capture HTTP traffic.
3. Setting Up JMeter for Test Recording
3.1. Launch JMeter
Open JMeter:
Navigate to the JMeter bin directory.
Run jmeter.bat (Windows) or jmeter (Linux/Mac) to start the JMeter GUI.
3.2. Configure HTTP(S) Test Script Recorder
Add HTTP(S) Test Script Recorder:
In the JMeter GUI, right-click on Test Plan.
Select Add > Non-Test Elements > HTTP(S) Test Script Recorder.
Configure HTTP(S) Test Script Recorder:
Port: Set the port number on which JMeter will listen for HTTP requests (e.g., 8888).
Controller: Choose the HTTP Request Defaults or create a new HTTP Request Defaults if you need specific settings for the recorded requests.
Target Controller: Select where the recorded requests will be added in your test plan (e.g., Thread Group).
Configure Recording Options:
URL Patterns to Exclude: Specify URL patterns that should not be recorded (e.g., static resources like images or scripts).
URL Patterns to Include: Define URL patterns to focus the recording on specific parts of your application.
3.3. Set Up Browser Proxy
Configure Proxy Settings:
Open your browser's proxy settings.
Set the proxy server to the same port as configured in the JMeter HTTP(S) Test Script Recorder (e.g., 8888).
Install JMeter's Root CA Certificate (for HTTPS traffic):
In JMeter, go to Options > Generate Self-Signed Certificate.
Follow the instructions to add the certificate to your browser’s trusted certificate authorities.
4. Creating and Configuring the Test Plan
4.1. Start Recording
Start the Recorder:
Click the Start button in the HTTP(S) Test Script Recorder section of JMeter.
Perform Actions in Your Browser:
Interact with your web application to capture the desired HTTP requests.
Stop Recording:
Click the Stop button in JMeter after completing the actions.
4.2. Save the Recorded Test Plan
Save the Test Plan:
Save your test plan with a .jmx extension (e.g., TestPlanName.jmx).
Add Necessary Files:
user.properties: Contains JMeter settings.
5. Executing the Load Test
5.1. Run the Test for 1 User
Prepare Directories:
mkdir runs/v4u1/report
Run the Test:
jmeter -n -t TestPlanName.jmx -j runs/v4u1/jmeter.log -l runs/v4u1/results.csv -e -o runs/v4u1/report/
-n: Run JMeter in non-GUI mode.
-t: Specify the path to the test plan file.
-j: Specify the path to the JMeter log file.
-l: Specify the path to the results file.
-e: Generate a report.
-o: Specify the path to the output folder for the HTML report.
Outputs:
runs/v4u1/jmeter.log: JMeter log file for the test execution.
runs/v4u1/results.csv: CSV file containing the load test results.
runs/v4u1/report/: Folder containing the generated HTML report.
5.2. Run the Test for 10 Users
Open JMeter in GUI Mode:
jmeter
Configure Thread Group:
In the Thread Group properties, set:
Number of Threads (Users): 10
Ramp-Up Period (in seconds): 2
Prepare Directories:
mkdir runs/v4u10/report
Run the Test:
jmeter -n -t TestPlanName.jmx -j runs/v4u10/jmeter.log -l runs/v4u10/results.csv -e -o runs/v4u10/report/
Outputs:
runs/v4u10/jmeter.log: JMeter log file for the test execution.
runs/v4u10/results.csv: CSV file containing the load test results.
runs/v4u10/report/: Folder containing the generated HTML report.
6. Analyzing Results
6.1. Review Log and Results Files
Log File:
jmeter.log: Contains detailed logs of the test execution. Review for any errors or issues.
Results CSV:
results.csv: Provides detailed performance metrics such as response times, throughput, and error rates.
6.2. Review HTML Report
HTML Report:
Located in the report folder, this provides a graphical summary of the test results, including response time distributions, throughput, and error rates.
7. Conclusion
This report outlines the process of creating and executing a load test script in JMeter using the test recording function. By capturing real HTTP requests and configuring JMeter, you can simulate various user loads and assess the performance of your application. The steps include setting up JMeter, recording test scenarios, running tests in both GUI and non-GUI modes, and analyzing the results.
For further customization and advanced configurations, refer to the JMeter User Manual.
Comments