类 AbstractTask
java.lang.Object
com.github.myzhan.locust4j.AbstractTask
- 所有已实现的接口:
Runnable
- 直接已知子类:
AbstractTaskFactory,AbstractTaskSet
An
AbstractTask is the abstraction layer of test scenario, which requires subtypes to implement test scenario
in execute() method.
Instances of task is shared across multiple threads, the execute() method must be thread-safe.
If you call locust.run(new AwesomeTask()), only one instance of AwesomeTask is used by multiple threads.
This behavior is different from locust in python.- 从以下版本开始:
- 1.0.0
- 作者:
- zhanqp
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明abstract voidexecute()Test scenarios should be implemented in this method, like sending http request.abstract StringgetName()Get the name of task.abstract intWhen locust runs multiple tasks, their weights are used to allocate threads.voidonStart()This method will be executed once before the test loop.voidonStop()This method will be executed once after the test loop stopped, whether it ends in failure or not.voidrun()
-
构造器详细资料
-
AbstractTask
public AbstractTask()
-
-
方法详细资料
-
getWeight
public abstract int getWeight()When locust runs multiple tasks, their weights are used to allocate threads. When locust runs one task set with all the tasks, their weights are used to invoke "execute" method, which means RPS most of the time.- 返回:
- the weight
-
getName
-
execute
-
onStart
-
onStop
public void onStop()This method will be executed once after the test loop stopped, whether it ends in failure or not. By default, nothing will be executed -
run
-