安装python
安装httprunner
- 通过pip安装
$ pip3 install httprunner
- 如果你想跟上最新的版本,你可以使用 github 仓库 url 进行安装。
$ pip3 install git+https://github.com/httprunner/httprunner.git@master
- 如果您之前已经安装了 HttpRunner,并且希望升级到最新版本,则可以使用 -u 选项。
$ pip3 install -U httprunner
或者
$ pip3 install -U git+https://github.com/httprunner/httprunner.git@master
检查安装成功没有
安装 HttpRunner 后,系统中将添加5个命令.
-
httprunner: 主要命令,用于所有功能 -
hrun:httprunner run的别名,用于运行 YAML/JSON/pytest testcases -
hmake:httprunner make的别名,用于将 YAML/JSON 测试用例转换为 pytest 文件 -
har2case:httprunner har2case的别名,用于将 HAR 转换为 YAML/JSON 测试用例 -
locusts: used to run load test with locust
随便运行一个命令试一试:
$ httprunner -V # hrun -V
3.1.0
如果安装成功,就会提示上面的3.1.0
异常情况
- . httprunner 提示安装成功,但是运行不了
httprunner命令,windows系统提示httprunner不是内部命令,也不是可执行程序.请检查环境变量
++注意++: 如果用户变量和系统变量的path环境变量中都存在python的Scripts和Lib,系统变量会覆盖用户变量,请自行删除一个
使用提示
使用httprunner -h可获取httprunner命令的所有用法
$ 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