HttpRunner使用基础
1.安装
pip install httprunner
指定版本号安装
pip install httprunner==2.5.7
2.查看版本
hrun -V
3.使用抓包工具生成yml文件或者json文件
1)使用fiddler抓包后,选中想自动化的接口请求,点击file-Export Sessions-Selected Sessions,导出成har格式文件
2)在保存har文件的目录下使用命令行转文件格式
转成yml格式:har2case ss.har -2y
转成json格式:har2case ss.har
4.创建项目
hrun --startproject demo
5.执行用例
hrun **.yml
执行多个用例
hrun a.yml b.yml c.yml
执行文件夹a下的所有用例
hrun **/a/
遇到失败时不再继续运行后续用例
hrun **.yml --failfast
显示指定日志级别以上的日志
hrun **.yml --log-level debug
6.执行testcases报not found错误的解决方案
错误信息如上图时,需返回到项目根目录再去执行
7.同一个yml文件中,上个接口输出作为下个接口入参
第一个接口返回结果如图:
1)提取第一个接口的输出
2)第二个接口引用
8.同一参数下相同的参数名需用短横线-关联