A, locust after version 0.13 has abolished the use of min_wait and max_wait
min_wait = 3000
max_wait = 7000
Instead, use
wait_time = between(3,7)
The official explanation:
Two, request parameters using catch_response
Official Description:
Simply put, if you need locust in Fails to record the normal error message, you need to use catch_response to capture the request, it is marked as a success or failure
codes are as follows:
def on_start(self):
body = {"username":"scqy1","password":"123123"}
response = self.client.post("http://10.46.59.15/login",json=body,catch_response=True)
# 解析响应的json数据,后续就可以正常使用列表或者字典操作数据
newText = json.loads(response.text)
self.token = newText["result"]["token"]
if newText["code"] == 0:
response.success()
else:
response.failure("请求失败")
The official explanation about the success and failure:
Three, post request description of the parameters
First talk about the problems encountered, I used three parameter passing, get tips Figure
self.client.post("http://10.46.59.156:8002/login",body)
self.client.post("http://10.46.59.156:8002/login",body=body)
response = self.client.post("http://10.46.59.156:8002/login",data=body)
Finally, I succeeded into json
response=self.client.post("http://10.46.59.156:8002/login",json=body)
The official explanation:
Fourth, the execution order
Official website Description:
Fifth, the implementation of the program
Official website Description (results Google Translation):
Example:
class Run_test(HttpLocust):
# 此处必须使用task_set,否则会提示No Locust class found!
task_set = Test_yl
#此处必须使用between的方法,min_wait和的用法max_wait在0.13版本之后就被弃用了
wait_time = between(3, 7)