1 脚本
from locust import HttpLocust, TaskSet, task, between # 新建任务集 class TestLogin(TaskSet): @task def req_index(self): data = { "username": "admin", "password": "admin123456", } login_response = self.client.post('/XXX', data=data) # 访问设置 class RunTest(HttpLocust): task_set = TestLogin wait_time = between(1, 2) host = "https://www.baidu.com"
2 命令
locust -f login.py