TaskSet
官方介绍:Class defining a set of tasks that a User will execute.
也就是一个把多个task集合起来的一个类,集合内的task的用法与在user类中的并没有多大差异,例如:
from locust import TaskSet, task, FastHttpUser
class MyTask1(TaskSet):
@task
def task_001(self):
self.client.get(url='/')
@task
def task_002(self):
pass
class MyTask2(TaskSet):
@task
def task_001(self):
pass
@task
def task_002(self):
pass
class MyUser(FastHttpUser):
tasks = [MyTask1, MyTask2] # 权重1:1
# tasks = {MyTask1: 1, MyTask2: 2} # 权重1:2
标签:task,TaskSet,self,任务,tasks,测试,pass,def
From: https://www.cnblogs.com/khaikami/p/17715492.html