Zero-based learning interface testing-basic knowledge of interface testing

1. What is an interface ( API )?

1. Baidu entry explanation:

API (Application Programming Interface, application programming interface) is some predefined functions , the purpose is to provide applications and developers based on a software or hardware to access a set of routines without having to access the source code, or understand internal work The details of the mechanism .

2. Vernacular explanation:

Let's go to the restaurant to eat, first: order "fish-flavored pork" with the orderer at the front desk ; then: the orderer will pass our order to the back kitchen staff through the order system, and the back kitchen staff will make the dishes; finally : The restaurant staff will serve us.

In the whole process, we only need to pay attention to the input (that is, what dish we want to order, does the restaurant have the dish we ordered ), and the output (the final dish is indeed what we ordered), and there is no need to pay attention to the processing process and internal logic (after How the chef cooks).

spacer.gifspacer.gifspacer.gif Interface test basic screenshot.png


Second, the interface classification-internal interface and external interface:

1. Internal interface:

The interface for internal call of a program generally refers to a method, function, module, etc.

For example: Baidu Tieba posts require access to the login interface, and only after successful login can post. The login module is the internal interface.

2. External interface:

Provides an interface (third party) for external call of the program.

For example: when using Didi taxi to pay, you need to call WeChat / Alipay to pay. WeChat / Alipay payment is now an external interface for Didi.


3. What is an interface test?

1. Official explanation:

Interfaces between test system components : mainly used to detect the interaction points between external systems and systems and between various internal subsystems. The focus of the test : to check the data exchange, transmission and control management process, and the mutual logical dependencies between systems.

2. Vernacular explanation:

( 1) Whether the interface meets the business needs (going to the restaurant to eat: can you order food successfully, and serve food successfully)

( 2) Whether each field is normal (field: whether the dish name, order number and table number are correct)

( 3) Whether the actual result is consistent with the expectation (whether the dishes on the waiter and the dishes we ordered are the same, as for how the chef cooks, we do not pay attention)

3. Focus on the content of interface testing:

( 1) Business functions to be implemented by the interface

( 2) Different inputs correspond to different outputs

( 3) Error handling

( 4) Don't pay attention to the specific code implementation of the interface

4. Why do interface tests?

1. Can be involved in the test earlier.

For example: testing an interface after developing an interface, without having to wait for the entire module to complete before starting the test, reducing the risk of delay.

2. Cost savings, the earlier bugs are found , the lower the repair cost.

For example: discovering underlying bugs during functional testing may lead to project refactoring or postponement.

3. The interface test is completed, the front-end changes only need to test the front-end, saving time.

4. Many problems that cannot be found by the front end can be found.

For example, in the lottery, only three draws are allowed per day. After three times, the draw button on the front-end interface is grayed out. You can skip the restriction of the page by calling the interface and conduct the fourth draw. If there are no restrictions on the back-end interface, you can directly request the server and draw again; write a script to call the interface uninterruptedly to draw the lottery, and the biggest prize will definitely be drawn.

5. You can check the security and stability of the system.

For example, when searching, the front-end will filter out special SQL statements. If the back-end interface is not filtered, it will cause SQL injection.

6. Ability to check the system's exception handling.

For example: when buying a Jingdong product, the price of the product cannot be -1 yuan when placing an order through the front end , but the call interface can pass the parameter -1 yuan, and the interface needs to do this special treatment.

7. Interface testing is easier to automate and continuously integrate, reducing the labor cost and time of regression testing.

For example: run the interface automation script every time before the project goes online to ensure that the old interfaces and newly added interfaces are normal.


Guess you like

Origin blog.51cto.com/14790982/2486809