赞
踩
1、设置断言监控接口请求成功和失败,一定要再请求接口的时候添加catch_response=True这个参数,locust会通过自定义情况来判断接口请求的成功与否
(比如说接口返回404,500的时候,如果不添加此块代码,locust也会自动统计为接口请求是成功的)
response=self.client.post(接口地址,json=参数,catch_response=True)
if "login_pass" in response.txt:
response .success()
else:
response .failure("Can not login!")
可以在主函数中通过os.system("locust -f ability_locust.py --host=http://www.baidu.com") 来本地启动和调试locust
locust参考文档:https://cloud.tencent.com/developer/article/1594240
locust官方文档:https://docs.locust.io/en/stable/quickstart.html
locust代码demo参考文档:http://
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。