解决python3.7+locust1.0性能测试报错

问题描述:

python3.7.8+locust1.0,性能测试运行过程中接口测试请求为空。运行测试脚本报错如下:

报错信息1:

Exception: No tasks defined. use the @task decorator or set the tasks property of the User将从locust中导入的HttpLocust改为HttpUser,即from locust import HttpLocust改为from locust import HttpUser,将脚本中引用的所有HttpLocust都改为HttpUser

解决方法:

将从locust中导入的HttpLocust改为HttpUser,即from locust import HttpLocust改为from locust import HttpUser,将脚本中引用的所有HttpLocust都改为HttpUser.

报错信息2:

C:\Python3.7.8\python.exe C:/Users/Administrator/Desktop/api_test/locust/restful_api_locust.py
C:\Python3.7.8\lib\site-packages\locust\util\deprecation.py:14: DeprecationWarning: Usage of User.task_set is deprecated since version 1.0. Set the tasks attribute instead (tasks = [UserBehavior])
  "(tasks = [%s])" % task_set.__name__, DeprecationWarning)

解决方法:

将class WebsiteUser(HttpUser): 中的 task_set = UserBehavior 修改为 tasks = [UserBehavior]

猜你喜欢

转载自blog.csdn.net/DaisyCold/article/details/108261611