Httprunner3.X测试报告

1.环境准备

安装httprunner

pip install httprunner

检查是否安装成功

hrun -V

安装locust

pip install locust

如有报错,可能需要升级一下python -m pip install --upgrade pip后,安装成功。
检查:

locust --version

2.创建项目

创建项目:

httprunner startproject demo

创建项目不成功时,可能是由于python版本与不匹配.卸载httprunner重新安装低版本的httprunner

pip uninstall HttpRunner
pip install httprunner==3.1.11

3.脚本生成

安装抓包工具fillter,测试接口工具postman

fillter抓包格式为har。

har2case 转换fillter抓的har文件为ymal、json格式,运行

har2case demo.har -2y 或者 har2case demo.har -2j

4.执行脚本

运行测试用例,

hrun demo.yml

5.查看报告

1. 运行测试报告:

hrun testcases/demo.yml --html=reports/repost.html

2. 创建父目录下Locust文件locustfile.py:

from locust import HttpUser, task, between

class MyUser(HttpUser):
    wait_time = between(1, 5)

    @task
    def test_endpoint(self):
        self.client.get("/test?a=1&b=nihao")

3. 运行Locust:

locust -f locustfile.py --host=http://localhost:XXXX

4. 浏览器打开:localhost:8089

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值