This topic describes the types of variables provided by the automated regression feature and how to use the variables.

Background information

When you orchestrate test cases, you always need to pass or share parameters. This may lead to unrequired copy and paste operations. The automated regression feature of Enterprise Distributed Application Service (EDAS) provides diversified variables to ensure the mutability of test requests.

View variable types

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo. In the left-side pane of the Dubbo page, click Automated Regression (Test Case Management).
  3. In the top navigation bar of the EDAS console, select the required region from the region drop-down list. In the upper part of the Automated Regression (Test Case Management) page, select the required microservice namespace from the microservice namespace drop-down list. Find the required test case and click Details in the Actions column.
  4. In the upper-right corner of the Test Case Details page, click Variables. In the Variables panel, view the types of variables and how to configure variables.
    Note If a name is used by different types of variables, the variables take effect in the following sequence: output parameter extraction variables > environment variables > collective variables > custom global variables > output parameter extraction variables set as global variables.
    Variable type Scope Description
    Output parameter extraction variable The current test case

    If the current test case contains multiple steps, you can use variables of this type to extract one or more output parameters from the responses to upstream requests and use the parameters as input parameters in downstream requests.

    Output parameters extracted in a test case cannot have duplicate names.

    Environment variable All test cases

    A service may be tested in different environments. For example, you test the service in the test environment and deploy it to the online environment for automatic regression. However, a test case does not vary with the environment.

    In different environments, the domain names of the tested service are different. In this case, you can define environment variables. For example, you can define an environment variable named base_uri for each of the test and online environments. If you specify ${base_uri} in the request URL of a test case, you can use the test case in both environments only by switching the environment.

    The name of an environment variable must be unique in an environment, but can be duplicate across environments.

    Collective variable Test cases in a test case set

    You can configure variables that can be collectively used by test cases in a test case set. Collective variables of a specific test case set cannot be used by test cases out of the test case set.

    The name of a collective variable must be unique in a test case set, but can be duplicate across test case sets.

    Custom global variable All test cases

    The name of a custom global variable must be unique within an Alibaba Cloud account.

    Output parameter extraction variable set as a global variable All test cases

    The type of variable can be used in the following scenario: An output parameter extraction variable of a step in Test Case A is set as the global variable. If you reference the variable in a step of Test Case B, the system runs Test Case A, extracts the value of the variable, assigns the value to a variable of Test Case B, and then runs Test Case B.

    For example, you set the cookie variable used to obtain cookies in Test Case A as the global variable. If you use ${cookie} in Test Case B, the system runs Test Case A to obtain the value of the cookie variable and then assign the value to a variable of Test Case B.

    System function All test cases

    System functions allow you to customize input parameters to meet diversified needs. You can combine, replace, nest, or add strings for system functions as required.

    System functions can nest environment variables, collective variables, and global variables.

Set output parameter extraction variables

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo. In the left-side pane of the Dubbo page, click Automated Regression (Test Case Management).
  3. In the top navigation bar of the EDAS console, select the required region from the region drop-down list. In the upper part of the Automated Regression (Test Case Management) page, select the required microservice namespace from the microservice namespace drop-down list. Find the required test case and click Details in the Actions column.
  4. On the right side of the Test Case Details page, click Visit Once. In the Debugging Result of Single Step panel, view the input and output parameters of a step, and click Output Parameter Extraction.
  5. In the Output Parameter Extraction dialog box, click the parameters you want to extract to copy the parameter expressions, and click OK.
  6. On the Step Configuration tab of the Test Case Details page, click the show icon icon in the upper-right corner to show the parameters.
  7. Click the Output Parameter Extraction (Optional) tab. In the table that appears, paste the parameter expressions you copied in the Output Parameter Expression column and name the parameters in the Output Parameter Name column.
    Note In the subsequent steps, reference the parameters in the format of ${Output parameter name}, such as ${code}.

Set environment variables

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo. In the left-side pane of the Dubbo page, click Automated Regression (Test Case Management).
  3. In the top navigation bar of the EDAS console, select the required region from the region drop-down list. In the upper part of the Automated Regression (Test Case Management) page, select the required microservice namespace from the microservice namespace drop-down list. Find the required test case and click Details in the Actions column.
  4. Add environment variables.
    1. In the upper-right corner of the Test Case Details page, click Variables.
    2. In the Environment Variables section of the Variables panel, click the add icon.
    3. In the Add Environment Variables dialog box, click Add to add environment variables that can be used in specific environments. Enter the information in the Name, Value, and Remarks columns as required, and click OK.
      Note A variable name must start with a letter and can contain only underscores (_), hyphens (-), letters, and digits.
  5. Modify environment variables.
    1. In the upper part of the Test Case Details page, select the required environment from the Environment Variables drop-down list and click the edit icon next to the name of the environment.
    2. In the Edit Environment Variables dialog box, modify the variable names, variable values, and remarks on the variables. You can also click the Delete icon in the Actions column to delete the variables. Click OK.
      Note A variable name must start with a letter and can contain only underscores (_), hyphens (-), letters, and digits.
    3. Optional:Alternatively, click Variables in the upper-right corner of the Test Case Details page. In the panel that appears, click the add icon in the Environment Variables section. In the dialog box that appears, you can modify or delete environment variables.

Set collective variables

To set collective variables, you must add the required test case to a test case set.

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo. In the left-side pane of the Dubbo page, click Automated Regression (Test Case Set).
  3. In the top navigation bar of the EDAS console, select the required region from the region drop-down list. In the upper part of the Automated Regression (Test Case Set) page, select the required microservice namespace from the microservice namespace drop-down list. Find the required test case and click Details in the Actions column.
  4. On the Test Case Set Details page, click the Variable Settings tab.
  5. In the Collective Variables section, enter the name and value for a collective variable in the Name and Value columns. You can also click the delete icon in the Actions column to delete the variable. After you configure the settings, click Save Test Case Set.
    Note A variable name must start with a letter and can contain only underscores (_), hyphens (-), letters, and digits.

Set custom global variables

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo. In the left-side pane of the Dubbo page, click Automated Regression (Test Case Management).
  3. In the top navigation bar of the EDAS console, select the required region from the region drop-down list. In the upper part of the Automated Regression (Test Case Management) page, select the required microservice namespace from the microservice namespace drop-down list. Find the required test case and click Details in the Actions column.
  4. In the upper-right corner of the Test Case Details page, click Variables.
  5. In the Custom Global Variables section of the Variables panel, click theedit icon.
  6. In the Edit Custom Global Variables dialog box, enter the name and value for a custom global variable in the Name and Value columns. You can also click the delete icon in the Actions column to delete the variable. After you configure the settings, click OK.
    Note A variable name must start with a letter and can contain only underscores (_), hyphens (-), letters, and digits.

Set output parameter extraction variables as global variables

  1. Log on to the EDAS console.
  2. In the left-side navigation pane, choose Microservices Governance > Dubbo. In the left-side pane of the Dubbo page, click Automated Regression (Test Case Management).
  3. In the top navigation bar of the EDAS console, select the required region from the region drop-down list. In the upper part of the Automated Regression (Test Case Management) page, select the required microservice namespace from the microservice namespace drop-down list. Find the required test case and click Details in the Actions column.
  4. On the Step Configuration tab of the Test Case Details page, click the show icon in the upper-right corner to show the parameters.
  5. Click the Output Parameter Extraction (Optional) tab. In the table that appears, enter the names and expressions of the extracted output parameters in the Output Parameter Name and Output Parameter Expression columns. Click Set as Global Variable in the Actions column.
  6. Click Save Configuration in the upper-right corner of the Test Case Details page, and click Variables.
    You can view the information about the variables that you have set as global variables in the Output Parameter Extraction Variables Set as Global Variables section of the Variables panel.