[Introduction to interface automation testing] Interface automation testing from 0 to 1

Some time ago, I wrote a series of articles related to automated testing, of course, more from the perspective of methods and problem-solving ideas to explain some of my views. This article talks about how novices can practice interface automation testing from zero to one.

Why do interface testing

Evolution of the test concept

Earlier, most of the software development and delivery processes followed a V-shaped or W-shaped waterfall model. In this model, only when the development and coding are completed will the test be promoted and enter the testing and verification stage. At this stage, most of the testing students do is based on the functional testing of business processes and pages, which is our self-deprecating "dot work".

In recent years, with the acceleration of business iteration and the continuous development of the testing industry, concepts such as shifting left testing and agile testing have begun to be recognized by more people. From the perspective of software engineering, the earlier you intervene to discover problems and risks, the lower the cost of repair and the higher the quality of final delivery.

When automated testing was the most popular in the past few years, many students should know the test pyramid model. See below:

According to some theories or the best practices of major manufacturers, the proportion of automated testing at the UI:API:UNIT layer should be 1:2:7, for the following reasons:

  • UI: high maintenance cost, late intervention time, minimal benefit;
  • API: The maintenance cost is moderate, you can intervene as early as possible, and cover many scenarios;
  • UNIT: The maintenance cost is the smallest, you can intervene earlier, the test granularity is the smallest, and the income is the highest (as for who will write the unit test, of course it is development);

Improvement of technical requirements

Most of the test students in China are technically weaker than development.

In order to continuously improve the delivery quality of the software system, it is necessary to expand the test coverage scenarios and the depth of the test as much as possible, which puts higher requirements on the technology of the test students.

With the increasing complexity of the system and the application of new technologies such as microservices, cloud native, server mesh, etc., in order to understand the tested object so as to better carry out the work, the technical requirements of the testing position are also getting higher and higher.

From the UI level test at the beginning, it has been continuously drilled down. It is an inevitable trend of evolution that the proportion of API layer test in daily work is getting higher and higher. API testing also has 2 features:

  • Compared with the UI layer test, it can be involved earlier, and the coverage of the UI layer can be continuously increased;
  • Compared with the UNIT layer test, the difficulty is lower, and the unit test of some public interfaces can be gradually covered downward;

It not only improves the technical standards, but also can make output KPI, and at the same time, it also improves the quality of software delivery, killing three birds with one stone, and winning numbness.

Understanding interfaces and interface testing

How to understand the interface?

To put it simply, the interface is an intermediary, which is responsible for the transformation of the business scenarios of the interface layer and the implementation logic interaction of the code layer.

The interface follows certain rules and constraints. Inputting specific data will return specific data, and the logic of input and output needs to be agreed in advance.

Calling each other between interfaces also needs to follow certain rules. This rule is the network protocol, such as: http protocol, tcp protocol, rpc protocol.

How to understand interface testing?

Interface testing is to test and verify the agreed input and output logic. Like functional testing, test cases also need to be designed.

The method of designing test cases is not much different from that of functional testing. It also needs to consider the equivalence class boundary value judgment table method and abnormal scenarios.

Of course, interface testing also needs to consider factors such as performance and security, but this is the field of other subdivision testing, so I won’t show it here for the time being.

How to learn interface testing?

The premise of learning interface testing is to understand the structure of different types of interfaces, so network protocols are a must. Related books are as follows:

  • Getting started: "Illustrated HTTP", "Illustrated TCP/IP"
  • In-depth study: "HTTP Authoritative Guide", "TCP/IP Authoritative Guide"

After understanding the structure of the interface, you need to learn some tools related to interface testing. The commonly used tools in the industry are as follows:

  • Packet capture tools: Fiddler, Charles
  • Testing tools: Jmeter, Postman
  • Interface generation management tools: Yapi, Swagger

The difference between UI/API/UNIT testing

UI, API, and UNIT tests have different characteristics. In summary, the differences are as follows:

  • UI testing: business process testing;
  • API test: business data flow test;
  • UNIT test: business implementation logic test;

How to implement automated testing of interfaces

Before discussing the interface automation testing for novices from zero to one landing, I would like to throw out some of my suggestions:

  • Start from scratch, don't go directly to learn the so-called automation framework;
  • Before learning the framework, it is necessary to learn network protocol and coding knowledge;

Why do you say that? Novices generally do not have a solid technical foundation and do not have much coding practice. It is especially easy to learn the framework directly step by step.

I have seen too many novices learn the framework directly, and there are many phenomena such as installation failure, incomprehensible error reporting, and inability to debug. There are also some students who don't know how to use code editors, don't understand logs, don't know how to package and so on.

To learn landing interface automation from scratch, or other automated tests, I recommend to practice from easy to difficult, so that on the one hand, you can give priority to the completion of work in daily work and improve work efficiency;

On the other hand, just like fighting monsters and upgrading, learn to improve yourself from easy to difficult, and constantly optimize the practice of automated testing at work.

From the first to the difficult implementation of automated interface testing, the following steps can be followed:

  • Learn to use tools for interface testing (such as jmeter/postman);
  • Learn to use continuous integration tools (such as jenkins) to execute interface test scripts in batches;
  • Learn version and source code management tools such as git/gitlab to facilitate multi-person collaboration in the team;
  • Learn a programming language and use an automated testing framework to convert tool scripts into code scripts;
  • Learn to encapsulate the common parts, optimize the code structure, improve the efficiency of writing code scripts, and reduce maintenance costs;
  • To learn the method of parameterized data management, you can iterate from the direction of Excel-configuration file-database-number factory;
  • Try to distinguish script collections according to business lines and test scenarios, and then introduce mocks to reduce call dependencies between services and improve execution efficiency;
  • Start to draw big pies, build wheels, engage in KPIs, and develop automated testing platforms;

The following is the supporting information. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

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

Information acquisition method:

Guess you like

Origin blog.csdn.net/IT_LanTian/article/details/131723276