All Products
Search
Document Center

Performance Testing:Add conditional judgment instructions

Last Updated:Mar 11, 2026

When a stress test scenario requires branching logic -- for example, calling different APIs based on a response value from a previous request -- you can use conditional judgment instructions to control which APIs execute based on whether specified conditions are met.

How conditional logic works

PTS supports two logical relationships between conditions, determined by how you arrange them in the scenario editor:

ArrangementLogical relationshipBehavior
Nested (one condition inside another)ANDAll conditions must be true for the API to execute
Parallel (conditions at the same level)ORThe API executes if any one condition is true

PTS evaluates conditions in sequence during stress testing. An API executes only after the conditions in its branch are satisfied.

Supported value types for conditions

The judgment object and comparison value in a condition accept the following types:

Value typeSupportedDescription
String literalYesFixed strings such as "success" or "200"
Response parametersYesOutput values extracted from a previous API in the scenario
Global parametersYesParameters defined at the scenario level
Custom parametersYesUser-defined variables
File parametersYesValues loaded from external data files
System functionsNoCannot be used as judgment objects or comparison values
Mixed parameter-string expressionsNoConcatenations of parameters and strings are not supported

To match against multiple values or patterns, use regular expressions in the comparison value.

Add a conditional judgment instruction

  1. Log on to the PTS console and choose Performance Test > Create Scenario. Click PTS.

  2. Configure the request parameters of an HTTP node. For more information, see Basic request parameters.

  3. Configure response parameters for the initial API so that subsequent conditions can reference the output values. For more information, see API response parameters.

    Response parameters configuration

  4. In the Business Session section, click the Add Instruction drop-down list and select Conditional Judgment.

  5. Expand Start Conditional Judgment and configure the Condition parameter.

    Condition configuration

Note

Conditional judgment instructions must be used in pairs (a start and an end block). The judgment object must reference a parameter, such as a file parameter, a response parameter from a previous API, or a custom parameter.

Examples

AND condition: both conditions must be true

Goal: Execute an API only when para is between 10 and 100 (inclusive).

Logic: para >= 10 AND para <= 100

Setup: Nest the second condition (para <= 100) inside the first condition (para >= 10). Nesting creates an AND relationship -- both conditions must be true for the API to execute.

AND condition example

OR condition: either condition is sufficient

Goal: Execute an API when para is outside the range of 10 to 100.

Logic: para < 10 OR para > 100

Setup: Place both conditions at the same level (parallel) and add the same API call under each branch. Parallel arrangement creates an OR relationship -- the API executes if either condition is true.

OR condition example

Combined AND/OR condition

Goal: Execute an API when para3 equals 100 AND either para4 > 100 or para4 < 10.

Logic: para3 = 100 AND (para4 > 100 OR para4 < 10)

Setup: Place the two OR conditions (para4 > 100 and para4 < 10) at the same level, then nest both inside the AND condition (para3 = 100). The outer condition must be true, and at least one inner condition must also be true.

Combined AND/OR condition example