Take you to design interface automation test cases (1): extract and analyze interface information

1. The market status of the testing industry

With the changes in market demand, most companies will put forward the relevant requirements for interface automation testing when recruiting testers. Why is this so?

At present, the software architecture is basically separated from the front and back ends, and the main functions of the software are provided by the server. From the perspective of the entire software testing market, most testers still focus on functional testing and UI automation testing, that is, front-end page testing, and do not involve too much server-side testing. However, due to the increase in software development costs and the shortened development cycle and iteration cycle, only front-end page testing can no longer meet the quality requirements of the software.

The main object of server-side testing is the interface provided by the server, so it is also called interface testing. The advantage of interface testing is that the test can intervene in advance before the development of a front-end page is completed. The earlier the testing work is involved, the lower the cost of solving bugs, and the more stable the product will be. Therefore, interface automation testing has almost become the only way for the development of UI automation testers.

Interface testing is also divided into manual interface testing and interface automation testing. Manual interface testing can generally be done through interface tools such as posman or jmeter; after the interface functions become stable, code-level interface automation testing and continuous integration can be realized.

Judging from the current market demand, the proportion of interface automation testing talents in the market is relatively low, the salary is high, and the market gap is huge.

The content of this article is excerpted from the book "Interface Automation Test Project: Python 3.8+Requests+PyMySQL+pytest+Jenkins Implementation", which adopts the project-driven mode and establishes a basic and practical interface automation test framework through the Python library. The content structure is as follows:        

2. The system under test based on this article


This book uses the ZrLog blog system (https://www.zrlog.com/) as the system under test.

ZrLog was chosen for the following reasons:

The deployment process is relatively simple, and the functions and business logic are not complicated.
Its interface resources include common operations such as adding, deleting, modifying, and checking, and the data responded by the server is also in standard JSON format. These conditions provide convenience for learning the interface automation testing framework.
ZrLog has multiple deployment methods, including the Docker method, which is used in this book for deployment. Docker is a container technology. A container is a process running in an isolated environment. If the process stops, the container will be destroyed. The program runs in this virtual container, just like running on a real physical machine. So, with Docker, you don't have to worry about environmental issues.

3. Extract interface information and analyze

The interface test is mainly to test the addition, deletion, modification, and query operations of server resources, so five interface information related to addition, deletion, modification, and query are extracted from the ZrLog system, which are the login interface, article publishing interface, and article modification interface. , delete article interface, query article interface. Before designing interface test cases, it is necessary to conduct preliminary understanding and analysis of these five interfaces, and to understand the relationship between interfaces, so as to prepare for the design of interface use cases.

1) Extraction and analysis of login interface information

Figure 1 shows the login interface information obtained through the Fiddler tool.

Figure 1 Login interface information

2) Extraction and analysis of published article interface information

Figure 2 shows the information of the published article interface obtained through the Fiddler tool.

Figure 2 Publishing article interface information

The information analysis of the publishing interface is as follows.

From the information shown in Figure 2, we can see that the interface for publishing articles uses the POST request method, the data type of the request is in JSON format, and carries cookies information, which means that the interface for publishing articles refers to the login interface in the requested information The variable information set (the variable set for the value of the admintoken field).
As can be seen from the text of the request, the value of title is "pay", which means that the title of the published article is "pay".
From the text of the response, we can see that when the article is published successfully, the server generates an id parameter, which is the id number of the article, and the id of the article published this time is 1. But it should be noted that this id number is dynamic, because every time a new article is published, the generated id number is different. If the downstream interface wants to modify or delete this article, it needs to quote this id number.
In the interface test case, how to make the downstream interface refer to the id information of the upstream interface? The value of id needs to be extracted and placed in a variable, and the downstream interface can directly refer to this variable to obtain the value of id.

3) Modify the extraction of article interface information

Figure 3 shows the information about modifying the article interface obtained through the Fiddler tool.

Figure 3 Modify the information of the article interface

The information analysis of the modified article interface is as follows.

From the information shown in Figure 3, we can see that the interface for modifying articles uses the POST request method, the data type of the request is in JSON format, and carries cookies information, which means that the interface for modifying articles refers to the login interface in the requested information The variable information set (the variable set for the value of the admintoken field).
As can be seen from the text of the request, the article with id 1 is modified this time, and the title of the article is changed from "Payment" to "Excellence in Contribution". However, since the article id changes dynamically, it is necessary to refer to the variable of the id set by the publish article interface when modifying the article.
4) Extraction of deleted article interface information

Figure 4 shows the information of the delete article interface obtained through the Fiddler tool.

Figure 4 Delete the information of the article interface

The information analysis of the delete article interface is as follows.

From the information shown in Figure 4, we can see that the interface for deleting articles uses the POST request method, the data type of the request is in form format, and carries cookies information, which means that the interface for deleting articles refers to the login interface in the requested information The variable information set (the variable set for the value of the admintoken field).
As can be seen from the text of the request, the article with id 1 is deleted this time, but since the id of the article changes dynamically, the variable set for the id in the publish article interface needs to be referenced when deleting the article.
5) Extraction of query article interface information

The content of this query is "excellent ability to pay", and the query articles obtained through the Fiddler tool are connected to

The port information is shown in Figure 5.

Figure 5 Query the information of the article interface

The information analysis of the query article interface is as follows.

From the information shown in Figure 5, we can see that the delete article interface uses the GET request method, so the content to be queried is directly placed in the interface address instead of in the request body. The query article interface also carries cookies information in the request header, which means that the query article interface references the variable information set by the login interface (the variable set for the value of the admin-token field) in the request header.
From the text of the response, we can see that the value of the error field is 0, which means that the business query is successful, and the values ​​of the total and records fields are both 0, which means that the article "Excellence through hard work" has been completely deleted, and no query has been found. Record.
6) Interface association summary

Through the above interface analysis, the following conclusions can be drawn.

The publishing interface is associated with the login interface.
The article modification interface is associated with both the login interface and the article publishing interface.
The delete article interface is associated with both the login interface and the publish article interface.
The query article interface is associated with the login interface.

Finally, I would like to thank everyone who has read my article carefully. Reciprocity is always necessary. Although it is not a very valuable thing, you can take it away if you need it:

insert image description here

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

These materials should be the most comprehensive and complete preparation warehouse for [software testing] friends. This warehouse has also accompanied tens of thousands of test engineers through the most difficult journey. I hope it can help you too! 

Guess you like

Origin blog.csdn.net/qq_48811377/article/details/132380222
Recommended