Interface test the basic theory

  introduction

"Interface test" a very high-end people think of the term, especially for students just getting started testing purposes. With the testing technology continues to deepen, "interface test" appears in our field of vision of increasing frequency. Then the interface test in the end is how to do? Advantages of interface testing has been reflected in what areas?

 

  What is the interface

Baidu Encyclopedia quoted sentence - Interface: point of interaction between the system and the system between the external and internal subsystems

The interface is generally divided into two types: internal program interface, the system external interfaces.
1. System external interface: for example, the most common system external interface - Alipay payment interface, many app payment features are invoked Alipay payment interface to make payments, and this interface is to provide a call to an external system Alipay system
2. program internal interfaces: interactions between the module and the module, such as Taobao Mall to purchase goods, you must first log in before placing orders, the orders between the login is an interactive, this interaction is an interface to allow other modules inside the program call. In addition internal procedures direct interface method calls. For example, interface calls between the foreground and background of electronic business platform, front desk and other developers with HTML or CSS or JS technology, background development staff with JAVA, PYTHON and other languages, if the user input data from the front desk, and how the data transmitted back it? Data transfer is mainly achieved by the front and rear ends of the get or post http protocol requests, which are part of an interface test.

 

  Common types

1.webService Interface: http transmission protocol to go through the soap, the request packet and return messages are xml format. You need to be invoked through the tool to test, test. Few companies are still using this kind of interface, such as hospitals and other industries.

2.http api Interface: http protocol away, distinguished by the method call path, and request packets are in the form of key-value, the packets are generally returns json string with get and post like. For now, the most commonly used. RESTful-based interface such as http protocol.

3.dubbo Interface: go rpc protocol, using rpc protocol for remote call directly using socket communication. High transmission efficiency, and can call the relationship between the statistics of the system, the number of calls. Using the Java language development, can only be used for communication between the Java language project development, it does not have the cross-language, cross-platform features!

4. Hardware Interface: USB, charging port (not discussed here)

Interface types, you can refer to my other article: Django Web interface development

  The difference between the front and rear end

Interface testing to do before, you need to understand the two concepts, front and rear
1. Front: usually for the Web and app, the front tip of the tip of the role of data in order to show content, to do simple data validation, such as we see Taobao Mall, those commodity information, Photo Gallery, and so on.
2. Rear: calculation of complex business logic, functions to achieve, for example, we calculate the purchase price of the commodity, the use of promotions, the final payment is through back-end implementation, while the front and rear ends that interact through interfaces of.

 

  Call diagram of the interface

 

 

 

Description: the reference input conditions i.e. packets, after processing interface program, the output result obtained, i.e. the reference packet.

 

  What is the interface testing

Baidu Encyclopedia is quoted saying: interface test between system components. Mainly between the detection system and the external system, and the interaction between the internal point of the various subsystems, inspection data exchange, transmission, management and control process, and the mutual logical dependencies between systems, adapted to provide a service to other systems underlying framework and system service center system, the main test system interface to external systems such provided, verify its correctness and stability.

 

Interface Test on to say:

1. Interface Test i.e. functional testing, by the test input conditions, the interface returns the results are consistent with the expected results.

2. The interface is used to connect the client and server, the data returned is generic interface json format.

3. The test interface test data is substantial, various database operations (add, delete, change, search).

4. The interface test is actually a very simple process, business logic processing interface as black box testing black box, we only need to consider a variety of input conditions, what will produce the appropriate results.

  That black box interface testing

Interface testing is black box testing, black box testing, but not necessarily the only interface testing.

And we know that black box testing, also known as functional testing, the interface testing and functional testing is not it all about? The answer is no, why? Functional test also includes the UI layer procedures, including buttons, interactive UI functions, and the interface of the test operation is not a page, can be tested by calling the interface, the interface is transmitted just give the corresponding input conditions, and then check the interface the results can be output meets expectations. To some extent, interface testing even simpler than some of the functional test.

 

  The composition of the interface

  1. Interface documentation;

  2. Interface url;

  3. The request method: post or get

  4. The request parameters, parameter types, the request parameter description;

  5. Return Parameters;

Interface seen from the document, the interface should be at least the address request, the request method, the request parameters (the parameters and the reference), with the first part of the interface there is a request header, cookie.

Header (header): HTTP protocol server to pass data to the browser HTML before sending string, still need a blank line separation between the header and the HTML file, the general store cookie, token and other information

So, header and to the Senate have anything to do? They are not all the parameters sent to the server do?

First, they are indeed sent to the server in the parameters, but they are different, the parameters stored in the header are some of the general store parity information, such as the cookie , it is to verify that the request has permission request to the server, If there is, it can request that the server, then the request address is sent to the server along with the parameters together, the server then returns a reference to the address and the parameters. In other words, the server is to accept the header information to determine whether the request has permission request, after the judge has authority, will accept the request and address the Senate.

 

  Why do interface testing

 

 

We know that by drawing, the front end of the program (UI layer) is used to display data and simple data validation, but the real core of the back-end business logic.

In the traditional functional test, if not the front-end front-end engineers work done, we can not expand the test is the test work, on the other hand, since the front end check function, it is likely to miss the back-end data of the function check if the user capture by bypassing the front-end, back-end operations directly, our program on major issues that may arise.

So test interface is mainly because:

  1. The test involves costs as soon as possible, the sooner the intervention tested and found to solve the problem is the lowest. Many times developers will not have to submit a complete product testing, the test does not work, there will be most of the time in a wait state, and the interface test can be tested without a front-end interface
  2. Back-end functionality verification is difficult to test in front because the front has a preliminary check control, so the interface test can find a lot of problems can not be found in the front
  3. Enhance the test efficiency, reduce labor costs and time costs of manual regression testing, shorten test cycles

 

 

  UI interface testing and comparison of the merits test

 

 

  • Interface testing intervention sooner, the earlier the intervention the higher the value.
  • More stable interface testing, the less change. Interface testing through instant front-end problems, solving them will be very fast
  • After tests found defects in the interface, the lower cost solution. The more the underlying defect, the more extensive the impact of surface, a bottom defect may cause defects on the surface of the N, then solve them will be very troublesome, but not necessarily be able to find the source of the defect
  • Locate the problem more accurately and quickly. When we tested the interface through function tests appear in the issue, we can more quickly and accurately locate the problem, as it has been ruled out interference out of the interface layer.

 

 

  Interface testing process

Principles of interface testing with functional testing is the same, then it's actually flow with functional testing process is basically the same.

Interface testing is not equal interface test tools

Many people would think that using an interface test tools will interface testing. In fact, far more than use interface test tools, SoapUI Ye Hao, Jmeter Ye Hao, these tools are our interface testing process making it easier to test, but the tool is only a tool, the real core of the test case or Interface design and test of thinking. So when we do interface testing, in the end what work needs to be done then?

Interface testing process:

  1. Acquisition requirements documents and interface documentation
  2. Through the analysis of the requirements document business requirements and business logic interface boundary
  3. By analysis of the interface document interface specifications (interface address, the request mode, the parameters, the parameters)
  4. Interface test case design (focused on the interface test data preparation)
  5. Using an interface test tool interface testing
  6. Interface defect management and tracking
  7. Automated continuous integration interfaces

 

 

  Common interface test tools

  Interface testing tool for many, such as postman, jmeter, loadrunner, SoapUI other, more common is the postman and jmeter. Introduction The following postman and jmeter.

  1.Postman is the Google of an interface test plug-in, which uses simple, support the use case management, support get / post, file upload, response authentication, variable management, environmental parameters management and other functions, you can batch run, and support the export of use cases, import .

  2.jmeter is a free open source tool written in 100% pure Java, it is mainly used for performance testing, compared to loadrunner speaking, its small memory footprint, free and open source, lightweight and convenient, without having to install, more and more public favorite.

 

  Interface Test how do

1) the generic interface test case design

①, through verification: First of all it must ensure that this interface function is crippled, that is, by normal tests, the parameters of its interface documentation, incoming normal, if you can return the correct results.
②, combination of parameters: There is an interface operation goods, there is a field type, time pass 1 represents the modified commodities, id, product name, price one must pass, type pass 2 when deleting commodities, id is a must pass, so, we must measure the combination of parameters, pass the time type 1, only passing trade names can not be modified successfully, id, name, price can not be modified when the transfer was successful.

③, interface security:
     1, bypass the validation, for example, to buy a commodity, its price is $ 300, then I submit an order, I put the price of this product into $ 3, there is no back-end verification. Genghen point, I put the money into a -3, is not my balance but also increase?
     2, bypassing the identity of the authorized product information such as modifying the interface, it must get the seller to modify, then I pass an ordinary user can not modify success, I pass one of the other sellers can not be modified successfully
     3, parameters are encrypted, For example, I landed interfaces, user names and passwords are not encrypted, if not encrypted, then someone intercepting your request, you will be able to obtain information, and encryption rules are easy to crack.
     The complexity of the check 4, password security rules, the password

④, abnormal verification:
  the so-called abnormalities verification, that is, I do not enter parameters in accordance with the requirements of your interface documentation to verify the interface check on abnormal situations. For example, do not fill the required parameters, enter the integer type of the incoming string type, length is 10, 11 pass, in short, is how come you say, how come I do not, in fact, also three, will pass non-essential passed, the parameter type, the parameter length.

2), according to business logic to design use cases
  designed according to business logic, then, is based on their own business systems to design use cases that each company's business is not the same, you have to specifically look at their company's business, but in fact this is also functional test design use cases is the same.
      For example, take the bbs, the demand bbs is this:
      1, Login failed five times, and then have to wait another 15 minutes to log
      2, requires newly registered users can post messages through the internship
      3, delete posts deducted points
      4, ......
     you take these test points listed like this, and then go make the test data corresponding test points.

 

 

 

  Request Status Code Description

  2 at the beginning of 1200 have expressed this request is successful, the most common is 200, on behalf of the request is ok, the server also returned.
  2,300 3 represents the beginning of the redirect, the most common is 302, this request is redirected to another place,
  the request on behalf of clients 3,400 400 sent a syntax error, 401 pages accessed without authorization on behalf of, 403 that there is no access to this page, not on behalf of the 404 pages
  begins with 5 representing 4,500 servers abnormalities, abnormal internal server 500 representatives, 504 representatives of the server-side timeout, did not return results

 

 

 

 

In this interface test tutorial, I will test the interface will be based on a detailed analysis of the testing process, we can continue to focus on this series, I believe you will be harvested.

 

Published 82 original articles · won praise 43 · views 180 000 +

Guess you like

Origin blog.csdn.net/liudinglong1989/article/details/104604625