Getting Started with HttpRunner: Installation, Quick Start, and Practical Usage
This article introduces HttpRunner, covering supported platforms, installation commands, key features such as parameter extraction, global configuration, variable handling, data-driven testing, report generation, and practical steps for converting HAR files to test cases and executing them with hrun.
Running Environment
Supported systems: macOS, Linux, Windows. Development environment: Python (recommended macOS/Linux with Python 3.6).
Installation
pip install httprunner
After installation, the following commands are available:
hrun : shortcut for httprunner, identical functionality.
locusts : performance testing based on Locust.
har2case : tool to convert standard HAR files to YAML/JSON test cases.
Verify installation with hrun -V .
Quick Start
1. Parameter association – extract values (e.g., token) from the first test case and reference them in subsequent requests using $var .
2. Global configuration – extract common parts of test cases into a config section.
3. Variable declaration and usage – define variables in variables and reference them with $var .
4. Data parameterization – create a debugtalk.py file alongside test cases to define functions and variables.
5. Data‑driven testing – use the parameters keyword to specify parameter names and data sources.
6. Test report generation – after running, an reports folder is created in the working directory containing an HTML result report.
Practice
1. Capture API traffic with Charles and export the HAR file.
2. Convert the HAR file to a test case using har2case path\test.har , which produces a JSON/YAML test case.
3. Execute the test case with hrun path\test.json .
Run Result
The execution generates an HTML test report inside the reports folder.
360 Tech Engineering
Official tech channel of 360, building the most professional technology aggregation platform for the brand.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.