Updated on 2024-06-06 GMT+08:00

Configuring a Case Script

After a test case is created, you can modify it as required.

Creating a Case Script

  1. Log in to the CodeArts PerfTest console and choose PerfTest Projects in the left navigation pane.
  2. Click the name of the desired PerfTest project to go to the details page.
  3. On the Cases tab, select the desired test case in the case list on the left.
  4. Click Case Script and select Pre-Steps or Steps.

    Pre-Steps are executed only once in each execution thread. This configuration is optional.

    Steps are executor of a test case, which needs to be configured.

  5. Add concurrency weight controllers, throughput controllers, requests, transactions, data sets, cycle controllers, condition judgments, and rendezvous points as required.

    You can add both requests and transactions, or add either of them. In practice, data sets, cycle controllers, condition judgments, and rendezvous points are used together with requests.

  6. When the configuration is complete, click Save.

Skipping a Request Upon Failure

When a request fails during case execution, the case does not report an error to terminate the execution. Instead, the case continues to execute subsequent requests. The failure of a request does not affect the execution of subsequent key steps.

  1. Log in to the CodeArts PerfTest console and choose PerfTest Projects in the left navigation pane.
  2. Click the name of the desired PerfTest project to go to the details page.
  3. On the Cases tab, select the desired test case in the case list on the left.
  4. On the Case Script tab page, find the desired request (AW).
  5. Click the second button () on the right of the request to configure whether to skip the AW request upon failure. The default value is No.

    • Yes: Skip a failed request. The case execution is not interrupted.

    • No: By default, a failed request is not skipped. The request failure does not interrupt case execution.

Samples

If request aw-1 is configured to be skipped upon failure, the system will skip the request failure and continue to execute the subsequent request aw-2.
Figure 1 AW that is configured to be skipped upon failure

Retrying a Request Upon Failure

When a request fails during case execution, the system retries the request based on the configuration, including the retry times and retry interval. If a request fails to be executed due to network or performance errors, configure retries for fault tolerance.

  1. Log in to the CodeArts PerfTest console and choose PerfTest Projects in the left navigation pane.
  2. Click the name of the desired PerfTest project to go to the details page.
  3. On the Cases tab, select the desired test case in the case list on the left.
  4. On the Case Script tab page, find the desired request (AW).
  5. On the Checkpoint tab, enable Enable Result Check to configure retry upon failure.

Samples

aw-1 is configured to be retried upon failure.
  • If the aw-1 request is successfully executed, the aw-2 request will be executed without retrying aw-1.
  • If the aw-1 request fails, it will be retried three times at an interval of 3000 ms based on the checkpoint.
    • If the aw-1 request is successful during the three retries, the aw-2 request will be executed.
    • If all the three retries fail, the aw-1 request fails, and the aw-2 request will be interrupted.
Figure 2 Checkpoint enabled for the aw-1 request

Disabling/Enabling a Case Request

If you want to retain a request of a case but do not want to use it, you can disable it. If you want to resume the use of the request, you can enable it again.

  1. Log in to the CodeArts PerfTest console and choose PerfTest Projects in the left navigation pane.
  2. Click the name of the desired PerfTest project to go to the details page.
  3. On the Cases tab, select the desired test case in the case list on the left.
  4. Disable a case request.

    On the Case Script tab, click next to the desired request to disable it. Other requests are not affected.

  5. Enable a case request.

    On the Case Script tab, click next to the desired request to enable it. Other requests are not affected.

Copying/Pasting a Case Request

  1. Log in to the CodeArts PerfTest console and choose PerfTest Projects in the left navigation pane.
  2. Click the name of the desired PerfTest project to go to the details page.
  3. On the Cases tab, select the desired test case in the case list on the left.
  4. On the Case Script tab, click > Copy next to the desired request. The copy is successful! is displayed in the upper right corner of the page.
  5. You can select a request in any project under PerfTest Projects, click > paste to front or paste to behind next to the request.