httprunner

2021-06-16  本文已影响0人  测试有话说

环境安装

C:\Users\Administrator>pip3 show httprunner
Name: httprunner
Version: 3.1.4
Summary: One-stop solution for HTTP(S) testing.
Home-page: https://github.com/httprunner/httprunner
Author: debugtalk
Author-email: debugtalk@gmail.com
License: Apache-2.0
Location: e:\programdata\anaconda3\lib\site-packages
Requires: requests, loguru, pytest-html, pydantic, black, jmespath, pyyaml, pytest, sentry-sdk, jinja2
Required-by:

相关命令

安装 HttpRunner 后,以下 5 个命令会写入系统环境变量配置。

•httprunner:

主命令,用于所有功能。

•hrun:

指令 httprunner run 的别名,用于运行 YAML/JSON/Pytest 测试用例。

•hmake: 指令 httprunner make 的别名,将 YAML/JSON 用例转换成 pytest 用例。

•har2case:

指令 httprunner har2case 的别名,将 HAR 文件转换成 YAML/JSON 用例。

•locust: 利用 locust 运行性能测试。

C:\Users\Administrator>httprunner
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

startproject 创建项目

C:\Users\Administrator>httprunner startproject zht_test_demo
2021-06-16 20:38:31.282 | INFO     | httprunner.scaffold:create_scaffold:43 - Create new project: zht_test_demo
Project Root Dir: C:\Users\Administrator\zht_test_demo

created folder: zht_test_demo
created folder: zht_test_demo\har
created folder: zht_test_demo\testcases
created folder: zht_test_demo\reports
created file: zht_test_demo\testcases\demo_testcase_request.yml
created file: zht_test_demo\testcases\demo_testcase_ref.yml
created file: zht_test_demo\debugtalk.py
created file: zht_test_demo\.env
created file: zht_test_demo\.gitignore

$ tree zht_test_demo -a
2021-06-16 20:38:31.290 | WARNING  | httprunner.scaffold:show_tree:29 - tree command not exists, ignore.
Sentry is attempting to send 0 pending error messages
Waiting up to 2 seconds
Press Ctrl-Break to quit

_____________________________________
C:\Users\Administrator>tree zht_test_demo
文件夹 PATH 列表
卷序列号为 0000016A 8819:D2F2
C:\USERS\ADMINISTRATOR\ZHT_TEST_DEMO
├─har
├─reports
└─testcases

make 转 pytest 用例

make 是把 YAML/JSON 测试用例转成 pytest用例, 需指定 yaml 文件路径或文件夹路径
httprunner make testcases

run 执行用例

httprunner run testcases

har2case

hrun

httprunner run testcases等价于hrun testcases

hmake

httprunner make testcases等价于 hmake testcases

locust

上一篇 下一篇

猜你喜欢

热点阅读