Skip to content

Conditional

This task executes one or more other tasks based on condition.

This is useful when a set of tasks should be executed if condition is True, and another set of tasks if condition is False.

All tasks created between step_task_conditional_if and step_task_conditional_end will be wrapped in this instance and executed conditionally. If the task has its own name attribute, it will be prefixed with this tasks name.

The step_task_conditional_else step expression is optional, if not used no additional tasks will be executed if condition is false.

Step implementations

Statistics

Executions of this task will be visible in locust request statistics with request type COND. name is suffixed with <condition> (<n>), where <condition> is the runtime resolved condition and <n> is the number of tasks that is executed for the resolved condition. Each task in the set for condition will have its own entry in the statistics, see respective Tasks documentation.

Arguments

  • name str: name of the conditional, used in locust statistics

  • condition str: Templating string that must render True or False