All Products
Search
Document Center

Performance Testing:Use a conditional jump instruction

Last Updated:Nov 01, 2024

You can use a conditional jump instruction to configure the execution path of a business session request based on the response parameters of an API. This topic provides an example on how to use a conditional jump instruction in typical e-commerce scenarios.

Background information

You can add a conditional jump instruction after you add APIs. Conditional jump instructions include jump, continue, and end instructions. If you configure multiple conditions, the logical relationship between the conditions is AND, and the conditions are matched in sequence during a stress test. If you configure conditional jump instructions, the logical relationship between the conditional jump instructions is OR.

In typical e-commerce scenarios, a user needs to complete the following steps: log on to the system, top up the account balance, add the product to the shopping cart, and then complete the payment. The user configures a conditional jump instruction to check whether the account balance is topped up in the step to add a product to the shopping cart. If the account balance is topped up, perform subsequent operations. If the account balance is not topped up, an API is provided to top up the account balance.

Procedure

  1. Log on to the PTS console, choose Performance Test > Create Scenario, and then click PTS.

  2. Add and configure the following APIs to complete the following steps: log on to the system, top up the account balance, add the product to the shopping cart, and then complete the payment. For more information, see HTTP APIs.

  3. Configure response parameters for the API of topping up the account balance. For more information, see API response parameters.

    示例配置出参

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

  5. Expand Conditional Jump and configure the Default Action parameter and jump conditions. The following figure shows an example.

    image

    • Default Action: You can select Jump, Continue, or End.

      • Jump: You can select another API for the business session.

      • Continue: You are redirected to the next API. If no subsequent APIs exist, the execution is complete.

      • End: The execution is interrupted.

    • Select Session: You can select the API for which you need to configure response parameters.

    • Action: You can select Jump, Continue, and End. If you select Jump, you must configure the API to which you are redirected.

    • Add Condition: Add a jump condition. The logical relationship between jump conditions is AND.

  6. Add the configured conditional jump instruction to the end of the API for adding the product to the shopping cart.