Automated regression testing for Spring Cloud service use cases

更新时间:
复制 MD 格式

The automated regression feature uses service contract information to orchestrate services and manage test use cases. This feature helps you efficiently run regression tests for business scenarios, which accelerates business validation and delivery. This topic describes how to create and run test use cases for Spring Cloud.

Create a Spring Cloud test use case

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Traffic Management > Microservices Governance > Spring Cloud.

  3. In the navigation pane on the left of the Spring Cloud page, click Automated Regression (Use Case Management).

  4. In the top menu bar of the Automated Regression (Use Case Management) page, select a region. On the page, select a microservices namespace, and then click Create Use Case.

  5. On the Create Use Case page, click the 下拉箭头 icon on the right and set the parameters.

    创建测试用例

    Configuration Item

    Description

    Use Case Name

    A custom name for the test use case.

    Application

    Select the application to test.

    Framework Type

    Select the Spring Cloud framework.

    Path

    Set the HTTP relative path. For example, /getIp.

    Basic Information

    Set the request method and ContentType. The request methods include GET, POST, PUT, and DELETE. The ContentType can be x-www-form-urlencoded or raw. Different ContentType values provide different visual ways to enter parameters.

    • x-www-form-urlencoded: Enter parameters in a form. The parameter format is [{"name": "cart"},{"age": 20}].

    • raw: The default format is application/json. The parameter format is {"name": "cart", "age": 20}. For other formats, parameters are transferred as plain text.

    For more information about the ContentType types that Spring Cloud microservices support, see Spring Cloud reference examples.

    Request Header

    Set the request header parameters.

    Assertion (Optional)

    Enter the Check Object and Check Content, and select a Check Condition.

    Response Parameter Extraction (Optional)

    Enter the Response Parameter Name and Response Parameter Extraction Expression.

  6. Click Access Once on the right. In the Single-step Test Result panel, view the request and response parameters for this request.

  7. Click Response Parameter Extraction Helper. In the Response Parameter Extraction Helper dialog box, click the name of the response parameter that you want to extract to copy it.

  8. Under Assertion (Optional), paste the copied parameter into the Check Object field. Select a Check Condition and enter the Check Content.

  9. Under Response Parameter Extraction (Optional), paste the copied parameter into the Response Parameter Extraction Expression field and specify a custom Response Parameter Name. Then, click Save Configuration in the upper-right corner.

    The created test use case appears in the use case list.

Create a multi-step chained test use case

Note

A test use case can contain multiple test steps. When a subsequent test step depends on the output of a previous test step, you must use parameter passing.

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Traffic Management > Microservices Governance > Spring Cloud.

  3. In the navigation pane on the left of the Spring Cloud page, click Automated Regression (Use Case Management).

  4. In the top menu bar of the Automated Regression (Use Case Management) page, select a region. In the Actions column of the target use case, click Details.

  5. On the Use Case Details page, click Access Once on the right. In the Single-step Test Result panel, view the request and response parameters.

  6. Click Response Parameter Extraction Helper. In the Response Parameter Extraction Helper dialog box, select and copy the response parameter that you want to extract.

  7. Under Response Parameter Extraction (Optional), paste the selected response parameter expression into the Response Parameter Extraction Expression field and specify a custom Response Parameter Name.

  8. Click the image icon to the right of +Add Test Step, and then click Add Test Step

  9. In the Basic Information section of the test step, set ContentType to raw. In the JSON Format field, enter the reference variable name ${XXX}.

    Note

    XXX is the Response Parameter Name set in the Response Parameter Extraction section of the previous step. Use the ${ } format for the reference.

  10. In the upper-right corner, click Save Configuration, and then click Execute Now.

Run a test use case

  1. Log on to the EDAS consoleEDAS console.

  2. In the left-side navigation pane, choose Traffic Management > Microservices Governance > Spring Cloud.

  3. In the navigation pane on the left of the Spring Cloud page, click Automated Regression (Use Case Management).

  4. In the top menu bar, select a region.

  5. You can run a test use case in one of the following ways.

    • On the Use Case List (Use Case Management) page, find the target use case and click Execute in the Actions column.

    • On the Use Case List (Use Case Management) page, find the target use case and click Details in the Actions column. On the Use Case Details page, click Execute Now.执行测试用例

    You can view the detailed execution results on the Execution History tab.

Related operations

You can also perform the following operations to manage test use cases.

  • Copy a test use case: On the Automated Regression (Use Case Management) page, find the use case that you want to copy and click Copy in the Actions column.

  • Delete a test use case: On the Automated Regression (Use Case Management) page, find the use case that you want to delete and click Delete in the Actions column.

Spring Cloud reference examples

ContentType

Parameter format

x-www-form-urlencoded

Enter key-value pairs in the form. The parameter format is: [{"name": "cart"},{"age": 20}].

raw

  • JSON (application/json): A JSON string, such as: {"name": "cart", "age": 20}.

  • XML (application/xml): An XML string of the application/xml type.

  • XML (text/xml): An XML string of the text/xml type.

  • HTML (text/html): An HTML string.

  • JavaScript (application/javascript): A JavaScript string.

  • Text (text/plain): A plain text format (TEXT/XML/HTML).