Automated API Test with Huawei Cloud: TestPlan

Enes Çetinberk
Huawei Developers
Published in
6 min readJul 25, 2023
CodeArts: TestPlan

Automated API Test with Huawei Cloud: TestPlan

Hello everyone! In this article of mine, i am going to show you how to perform automated API tests with Huawei Cloud CodeArts TestPlan service.

By reading this article, you will learn:

  1. How to write low-code automation script with TestPlan
  2. Creating test cases and grouping test steps
  3. Response Extraction, setting local variables
  4. Conditional statements with TestPlan

Introduction

Many of you may have used a test automation tool, either Selenium or Azure DevOps Testplan. Huawei Cloud CodeArts: TestPlan issegmented same with Azure DevOps Testplan in terms of functionality.

CodeArts: TestPlan is a one-stop test management platform (formerly CloudTest) that covers the entire test process from planning to design, cases, execution, and evaluation. In order to take advantage of Huawei’s years of high-quality software test engineering methods and practices to carry out collaborative, efficient, and trustworthy test activities for your product release, let’s get started with our hands-on experiencce.

Hands-on Experience

In this demo, we are going to prosecute the following steps:

  1. Logging in, Pre-requisites
  2. Creating a test case
  3. Inputting test steps and details
  4. Scripting
  5. Running & Checking Results

1. Logging-in, Pre-Requisites

At first, you need to log-in to Huawei Cloud Console. Then, access the CodeArts: TestPlan Service. Followingly, click on “Testing Case”.

Testing Case

2. Creating a Test Case

Click “Create” to create a test case.

Testing Case Dashboard

3. Inputting Test Steps and Details

Fill “Description”, “Pre-requisites”, “Testing Steps” and “Basic Information” as needed.

Details of Test Case

4. Scripting

When you move to the “Scripting” tab, you will see a working space for low-code API test worklfow.

Scripting Work Space

At the bottom of the workspace, you can see the set of tools you can use during your testing workflow. You can add “URL Request” with desired method(such as POST, GET, PUT , DEL, HEAD, OPT and PATCH). You can import your desired actions from Postman, you can give sleep time to your workflow, group your test case steps, perform logical operations with if-else statements and also put your testing steps into loop with the given set of tools. In this demo, we will group 2 URL Requests and a conditional statement in a loop.

4.1.1. In order to create a URL Request, click on the left-bottom button. Click once more to have 2 URL Requests.

4.1.2. Click Group to have a group item. Grouping your steps will form a readable workflow.

4.1.3. Click Loop to have a loop item. Iterative steps can be performed via this way.

4.1.4. Click If Condition to have this item.

4.1.5. Do drag-and-drop to have the following steps:

Testing Steps

4.2.1 Click on the first URL Request. Set your method to “GET” and enter your URL containing your API Key. You will see that your parameters will be automatically inserted. If not, you can insert your request parameters manually.

GET Request

4.2.2 Click on “Checkpoints” tab. Select “Response Code” as source. Select “==” as comparison operator. Then, input “200” as target value. Meaning that this test case will continue to next step if response code is “200, OK”.

Checkpoints

4.2.3 Now we need to extract some of the information from the response body of our URL request for using that information somewhere else. Click on “Extract Response” tab. Choose a desired parameter name as output parameter. Select “Response Body” as source. Query your property. In our case, we want to reach out to the comparison text where AccuWeather describes the weather in one sentence.

Extract Response

4.3 Now you have created a local parameter named “text”. In order to use this parameter in the following steps, we need to place “PUT” request in this step. Click on the next URL Request you have created. Set the method to “PUT”. Place the same URL as it is in the “GET” request with your API Key.

PUT Request

4.4 In the previous 2 steps, you’ve accomplished to test the connection with your API and managed to extract a parameter you can use in the upcoming steps. Now let’s test if we really made a successful extraction by IF-ELSE logical operation. Query your extracted parameter with the following syntax: ${parameter_name}. Select appropriate logical operator for your purpose. We choose “Equals” because this variable is a text. Input your value in the next text box. We expect “Not as hot Thursday” from AccuWeather API for Istanbul location.

Logical Operations

5. Running & Checking Results

When we click run, we expect an error if the parameter text is not equal to “Not as hot Thursday”. Also we expect an error if our “GET” URL request doesn’t get a “200, OK” response code. Let’s run and see the results.

Test Result

You can observe that we have received 200 response code from both URL requests and also our IF condition check has passed because the text parameter is equal to the desired value. After you examined your results, you can see the overall performance of your test team’s reports when you exit from “Test Case” sub-service of TestPlan and click “Quality Reports”.

Quality Report Tab
Quality Report

Congratulations! Now you can perform Automated Testing Workflows with CodeArts: TestPlan on youw own projects.

Conclusion

In summary, Huawei Cloud TestPlan service is a robust and user-friendly platform that empowers developers and testers to achieve comprehensive API test coverage efficiently. By leveraging this tool, teams can ensure the delivery of top-notch APIs that meet user expectations and drive business success. The key to successful API testing lies in its automation, and with Huawei Cloud TestPlan, you are well-equipped to navigate the complexities of modern API testing and build a strong foundation for your software projects.

Resources

--

--

Huawei Developers
Huawei Developers

Published in Huawei Developers

As Huawei Developers, our Medium publication where we share information about the use of Huawei Ecosystem

Enes Çetinberk
Enes Çetinberk