–
httprunner是一个开源框架,只需编写维护一份 YAML/JSON 脚本,从1.x到现在的3.x也在不断地优化更新,3.x版本继续继承优秀的request库并增加了pytest框架、allure报告、locust性能等,集接口、性能、自动化测试为一体的多种需求测试,当然也肯定是支持持续集成的。
安装httprunner:
pip3 install httprunner
更新httprunner:
pip3 install -U httprunner
检查安装版本命令:
- httprunner -V
(venv) lifeng@apple httprunnerDemo % httprunner -V
3.1.4
- hrun -V # httprunner 的别名
(venv) lifeng@apple httprunnerDemo % hrun -V
3.1.4
显示帮助信息:
(venv) lifeng@apple httprunnerDemo % httprunner -h
usage: httprunner [-h] [-V] {
run,startproject,har2case,make} ...
One-stop solution for HTTP(S) testing.
positional arguments:
{
run,startproject,har2case,make}
sub-command help
run Make HttpRunner testcases and run with pytest.
startproject Create a new project with template structure.
har2case Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner.
make Convert YAML/JSON testcases to pytest cases.
optional arguments:
-h, --help show this help message and exit
-V, --version show version
- run:使HttpRunner测试用例并与pytest一起运行。
- startproject:用模板结构创建一个新项目。
- har2case:将HAR(HTTP Archive)转换为HttpRunner的YAML / JSON测试用例。
- make:将YAML / JSON测试用例转换为pytest用例。
har2case这种文件可以直接在charles抓包工具上直接导出,格式选.har保存:
httprunnrr startproject xxxxx,快速创建项目工程目录
(venv) lifeng@apple apiHttprunner3.0 % httprunner startproject testDemo
2021-03-22 23:23:11.298 | INFO | httprunner.scaffold:create_scaffold:43 - Create new project: testDemo
Project Root Dir: /Users/lifeng/python-projects/AuomationTest/apiHttprunner3.0/testDemo
created folder: testDemo
created folder: testDemo/har
created folder: testDemo/testcases
created folder: testDemo/reports
created file: testDemo/testcases/demo_testcase_request.yml
created file: testDemo/testcases/demo_testcase_ref.yml
created file: testDemo/debugtalk.py
created file: testDemo/