当前位置:网站首页>Is interface automation difficult? Take you from 0 to 1 to get started with interface automation test [0 basic can also understand series]

Is interface automation difficult? Take you from 0 to 1 to get started with interface automation test [0 basic can also understand series]

2022-06-12 00:43:00 Little brother said test

front said

“ The interface test ” A very high-end term , Especially for the test students who just started . With the development of testing technology ,“ The interface test ” More and more frequently in our field of vision . So how does interface test work ? What are the advantages of interface testing ?

Catalog

front said

Interface

One 、 What is an interface ?

Two 、 Common types of interfaces

3、 ... and 、 The difference between the front end and the back end

The interface test

One 、 What is interface testing

Two 、 The composition of the interface

3、 ... and 、 Why do interface tests

Four 、 Interface test and UI Comparison of test advantages and disadvantages

5、 ... and 、 Interface test process

Learning resource sharing


Interface

One 、 What is an interface ?

Interface : Interaction points between external systems and internal subsystems

----- Baidu Encyclopedia

There are generally two types of interfaces : Program internal interface 、 External interface of the system .

1、 External interface of the system : For example, the most common system external interface — Alipay payment interface , quite a lot app The payment function is called Alipay payment interface to pay. , And the interface is invoked by the Alipay system to the external system.

2、 Program internal interface : Interaction between modules , For example, Taobao Mall needs to buy goods , You must log in before placing an order , So there is an interaction between placing an order and logging in , This interaction is an interface , Having other modules within the program call .

In addition, the internal method of the program directly calls the interface . For example, the interface call between the foreground and background of the e-commerce platform , Used by foreground developers HTML or CSS or JS Technology , Background developers use JAVA,PYTHON Other languages , If the user inputs data from the foreground , How to transfer data to the background ? Mainly through http Agreed get or post Request to achieve data transmission at the front and back ends , These are all part of the interface test .


Two 、 Common types of interfaces

  • webService Interface : go soap Agreement passed http transmission , Both request message and return message are xml Format . When testing, you need to pass the tool to call 、 test . A few companies still use this interface , Such as hospitals and other industries .

  • http api Interface : go http agreement , Differentiate called methods by path , Requests and messages are key-value Formal , The return message is usually json strand , Yes get and post Other methods . For now , Is the most commonly used . Such as RESTful be based on http Interface to protocol .

  • dubbo Interface :  go rpc agreement , Use rpc Protocol for remote calls , Use it directly socket signal communication . High transmission efficiency , And can count the call relationship between systems 、 Call the number . Use Java Language development , It can only be used for Java Communication between language development projects , No cross language skills , Cross platform features !

  • Hardware interface :USB 、 The charging interface ( No discussion here )

3、 ... and 、 The difference between the front end and the back end

Before interface test , Two concepts need to be understood , Front end and back end

  • front end : Usually it is Web Front end and app front end , The purpose of the front end is to show the data content , Simple data verification , For example, Taobao Mall we saw , What product information , Picture display, etc .

  • Back end : Business logic for complex computing , Function realization , For example, the price calculation after we buy the goods , Use of preferential activities , Final payment , All through the back end , The front and back end interact through interfaces .

Interface call diagram :

explain : The input condition is the input parameter message , After being processed by the interface program , Get the result output , That is, outgoing parameter message .

The interface test

One 、 What is interface testing

Interface test between system components . It mainly detects the relationship between the external system and the system , And the interaction points between the internal subsystems , Exchange of inspection data , Pass on , And control management process , And the mutual logical dependence between systems , The underlying framework system and central service system suitable for providing services for other systems , Mainly test the interfaces provided by these systems to external systems , Verify its correctness and stability .

----- Baidu Encyclopedia

About interface testing :
1、 Interface test is function test , By testing under different input conditions , Whether the result returned by the interface is consistent with the expected result .
2、 Interface is used to connect client and server , Generally, the data returned by the interface is json Format .
3、 The essence of interface testing is data testing , Various operations on the database ( increase , Delete , Change , check ).
4、 Interface testing is a very simple process , Treat the business logic processing of the interface as the black box in the black box test , We only need to consider all kinds of input conditions , What are the results .

Interface testing is black box testing , But black box testing is not necessarily just interface testing .

We know that black box testing is also called functional testing , that Is interface testing the same as functional testing ? The answer is No , Why? ?

The function test also includes the UI layer , Contains buttons ,UI Interaction And so on , The interface test has no page operation , Only by calling the interface To test it , Only the corresponding input conditions need to be passed to the interface , Then check whether the output of the interface meets the expectation . To some extent , Interface testing is simpler than functional testing .


Two 、 The composition of the interface

  • Interface description document

  • Interface url

  • Request method :post or get

  • Request parameters 、 Parameter type 、 Request parameter description

  • Return parameter description

From the interface documentation , Interface At least Request address 、 Request method 、 Request parameters ( In and out ) form , Some interfaces have request headers header,cookie.

header (header): It's the server that HTTP Protocol transmission HTML The string sent before the data is sent to the browser , In the header with HTML There is still a blank line between the files , General storage cookie、token Etc

that ,header What does it have to do with participation ? Aren't they all parameters sent to the server ?

First , They are really parameters sent to the server , But they are different ,header The parameters stored in are usually some verification information , such as cookie, It is to verify whether the request has permission to request the server , If there is , It can request the server , Then the request address is sent to the server along with the input parameter , Then the server will return out parameters according to the address and in parameters . in other words , The server first accepts header Information to determine whether the request has permission request , After judging that you have authority , Will accept the request address and parameters .
 

3、 ... and 、 Why do interface tests

From the picture we know , Front end of program (UI layer ) It is used to display data and simple data verification , and The core of the real business logic is the back end .

In traditional function testing , If the front-end engineer has not finished the front-end work , We can't start the test , On the other hand , Since the front end has verification function , Then the backend may miss the data verification of this function , If the user bypasses the front end by grabbing packets , Direct back-end operations , We could have major problems with our procedures .

So the main reason for interface testing is that :

  • Early test intervention , The earlier the intervention test , The cost of solving the problems found is the lowest . A lot of times when development doesn't submit the full product to testing , Unable to work during test , There will be a lot of waiting time , The interface test can be conducted without the front-end interface

  • It is difficult to test the function verification of the back end in the front end , Because the front end already has preliminary verification control , So interface testing can find many problems that cannot be found in the front end

  • Improve test efficiency , Reduce the labor cost and time cost of manual regression test , Shorten the test cycle


Four 、 Interface test and UI Comparison of test advantages and disadvantages

  • Interface test intervention time is earlier , The earlier the intervention, the higher the value .

  • More stable interface test , Little change . Interface test passed , There is an immediate problem in the front end , It's going to be very fast

  • After defects are found in interface test , Lower cost of solution . Defects beyond the bottom , The wider the impact , An underlying defect may cause N Surface defects , It's going to be a lot of trouble , And we don't have to find the source

  • Positioning problems more accurate and faster . When our interface test passes , Problems in functional testing , We can locate the problem more quickly and accurately , Because the interference of interface layer has been eliminated .

5、 ... and 、 Interface test process

The principle of interface test is the same as that of function test , So its process is basically the same as the function test process .

The interface test   It's not equal to   Interface test tool usage

Many people think that using interface testing tools is just interface testing . In fact, interface testing is far more than the use of tools ,SoapUI Good ,Jmeter Good , These tools are more convenient for us to test in the process of interface test , And tools are just tools , The real core part is interface test case design and test thinking . So when we do interface testing , What kind of work should we do ?

Interface test process :

  • Obtain requirements documents and interface documents

  • Analyze the business logic requirements and business boundary of the interface through the requirements document

  • Analyze the technical index of the interface through the interface document ( Address of the interface 、 Request mode 、 Enter the reference 、 The ginseng )

  • Interface test case design ( Focus on interface test data preparation )

  • Interface testing with interface testing tools

  • Interface defect management and tracking

  • Interface automation continuous integration
     

Common tools for interface testing :
There are many tools for interface testing , such as postman、jmeter、loadrunner、SoapUI etc. , It's common to see postman and jmeter.

Introduction postman and jmeter:

1、Postman Is an interface test plug-in of Google , It's easy to use , Support use case management , Support get/post、 Upload files 、 Response verification 、 Variable management 、 Environmental parameter management and other functions , It can run in batches , And support use case export 、 Import .

2、jmeter Is a 100% pure Java Write free and open source tools , It is mainly used for performance testing , comparison loadrunner Come on , It uses less memory , Free and open source , Light and convenient 、 No installation required , More and more popular .
 

How to do interface testing :

General interface use case design

1、 Through sexual verification :

First of all, make sure that the interface function is easy to use , That is, the normal passing test , According to the parameters on the interface document , Normal incoming , Whether the correct result can be returned .

2、 Parameter combination :

Now there's an interface to operate goods , There is a field type, Pass on 1 It means to modify the product , goods id、 Name of commodity 、 There is a price that must be passed on ,type Pass on 2 It's time to delete items , goods id   It must be passed on , In this way , It's time to measure the parameter combination ,type Pass on 1 When , Can I modify the name of the product ,id、 name 、 Can the price be modified successfully when it's all passed .

3、 Interface security :

  • Bypass verification , Like buying a product , Its price is 300 element , Then when I submit the order , I'll change the price of this product to 3 element , Does the backend verify , Harder , I changed the money to -3, Is my balance going to increase ?

  • Bypass identity Authorization , For example, modify the commodity information interface , It has to be the seller to modify , Then I'll send it to an ordinary user , Can you modify it successfully , I'll pass on whether another seller can modify it successfully

  • Is the parameter encrypted , For example, my login interface , Is the user name and password encrypted , If it's not encrypted , Someone else intercepted your request , You can get your information , Is the encryption rule easy to crack .

  • Password security rules , Password complexity check

4、 Exception verification :

So called exception verification , That is to say, I don't input parameters according to the requirements in your interface document , To verify the interface's verification of exceptions . For example, the required parameters are not filled , Enter the integer type , Passed in string type , The length is 10 Of , Pass on 11, In a word, it's just how you say it , I don't come much , In fact, there are only three kinds , Must pass, not must pass 、 Parameter type 、 The length of the input parameter .

Design use cases based on business logic

Designed according to business logic , It is to design use cases according to the business of your own system , The business of each company is different , It depends on the business of your company , In fact, this is the same as the function test design case .

for instance , take bbs Come on ,bbs This is the demand for :

1、 Login failed 5 Time , We need to wait 15 I'll log in in minutes

2、 New registered users need to go through the internship period to post

3、 Delete posts and deduct points

4、......

Like this, you have to list these test points , And then create the corresponding test point for data test .
 

Request status code description

  • 200 :2 The first ones indicate that the request was sent successfully , The most common is 200, On behalf of this request is ok Of , The server also returned .

  • 300 :3 The beginning represents redirection , The most common is 302, Redirected the request to another place ,

  • 400 :400 Syntax error in request sent on behalf of client ,401 The page visited by the representative is not authorized ,403 Indicates that you do not have permission to access this page ,404 No such page

  • 500 :5 The beginning represents an exception in the server ,500 Represents server internal exception ,504 Timeout on behalf of server side , No results returned


Learning resource sharing

Finally, thank everyone who reads my article carefully , Watching the rise and attention of fans all the way , Reciprocity is always necessary , Although it's not very valuable , If you can use it, you can take it

These materials , For those who want to advance 【 automated testing 】 For our friends, it should be the most comprehensive and complete war preparation warehouse , This warehouse also accompanied me through the most difficult journey , I hope it can help you ! Everything should be done as soon as possible , Especially in the technology industry , We must improve our technical skills . I hope that's helpful …….

原网站

版权声明
本文为[Little brother said test]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/163/202206120035127232.html