类 AbstractTask

java.lang.Object
com.github.myzhan.locust4j.AbstractTask
所有已实现的接口:
Runnable
直接已知子类:
AbstractTaskFactory, AbstractTaskSet

public abstract class AbstractTask extends Object implements Runnable
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 void
    Test scenarios should be implemented in this method, like sending http request.
    abstract String
    Get the name of task.
    abstract int
    When locust runs multiple tasks, their weights are used to allocate threads.
    void
    This method will be executed once before the test loop.
    void
    This method will be executed once after the test loop stopped, whether it ends in failure or not.
    void
    run()
     

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • 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

      public abstract String getName()
      Get the name of task.
      返回:
      the name
    • execute

      public abstract void execute() throws Exception
      Test scenarios should be implemented in this method, like sending http request.
      抛出:
      Exception - test scenarios may throw exception.
    • onStart

      public void onStart() throws Exception
      This method will be executed once before the test loop. By default, nothing will be executed.
      抛出:
      Exception - if an exception is thrown then a failure will be recorded and test scenarios will not be executed
    • 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

      public void run()
      指定者:
      run 在接口中 Runnable