All Products
Search
Document Center

Performance Testing:Use a conditional judgment instruction

Last Updated:Nov 01, 2024

You can add a conditional judgment instruction to configure multiple judgment conditions. You can determine the APIs that can be called based on the judgment conditions. This topic describes how to add a conditional judgment instruction and configure judgment conditions.

Background information

You can configure multiple judgment conditions. If the judgment conditions are nested, the logical relationship between the judgment conditions is AND. If the judgment conditions are parallel, the logical relationship between the judgment conditions is OR. During stress testing, the judgment conditions are checked in sequence. An API can be called only after all judgment conditions are met.

Procedure

  1. Log on to the PTS console, choose Performance Test > Create Scenario, and then 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. For more information, see API response parameters.

    image

  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.

    The judgment object and comparison value can be strings and parameters, including the response parameters of the previous API, global parameters, and custom parameters. You cannot set the judgment object or comparison value to a system function or a value that consists of parameters and strings. If you want to use a set or multiple comparison values, you can use regular expressions.

    image

    Note

    Conditional judgment instructions must be used in pairs, and the judgment objects must be set to values that consist of parameters, such as file parameters, response parameters of the previous API, and custom parameters.

Examples

This section provides three examples on how to configure a conditional judgment instruction.

  • Example 1: Condition A and Condition B are met. For example, the conditions are para ≥ 10 and para ≤ 100. In this case, you must nest the judgment condition (Icon ②) that requires a value less than or equal to 100 to the judgment condition (Icon ①) that requires a value greater than or equal to 10. The logical relationship between the two conditions is AND. The following figure shows the details.

    image

  • Example 2: Condition A or Condition B is met. For example, the condition is para < 10 or para > 100. In this case, the judgment condition (Icon ①) that requires a value less than 10 and the judgment condition (Icon ②) that requires a value greater than 100 are parallel. The logical relationship between the conditions is OR. You must call the same API to check the conditions in sequence. The following figure shows the details.

    image

  • Example 3: Condition C is met, and Condition A or Condition B is met. For example, the conditions are para3 = 100 and para4 > 100 or para4 < 10. In this case, the judgment condition (Icon ①) that requires the value of para4 be greater than 100 and the judgment condition (Icon ②) that requires the value of para4 be less than 100 are parallel and nested to the judgment condition (Icon ③) that requires the value of para3 be equal to 100. The following figure shows the details.

    image