当前位置:网站首页>How to conduct interface test? What are the precautions? Nanny level interpretation

How to conduct interface test? What are the precautions? Nanny level interpretation

2022-07-06 08:32:00 Software testing

1. What is an interface ?

The interface is mainly used for the interaction points between systems and subsystems within the program , Define specific interaction points , Then through these interaction points, that is, protocols , To interact with each other .

2. What are the types of interfaces ?

There are generally two types of interfaces :1. Program internal interface 2. External interface

** External interface :** Such as : Wechat payment interface , Alipay payment interface, etc.

Program internal interface : Between methods , Interaction between modules , The interface thrown inside the program , For example, e-commerce system , There are login modules 、 Submit order module, etc , To pay, you must log in , Then the two modules have to interact , The system will interact with data through an interface .

** Classification of interfaces :**1.webservice Interface 2.http agreement (api Interface )

webService The interface is to go soap Agreement passed http transmission , Both request message and return message are xml Format , When we test, we can use SoapUI Call and test tools .

api The interface is to go http agreement , Differentiate called methods by path , The request message is key-value Formal , The return message is usually json strand , Yes get,post,put,delete And other four common request methods .

json Is a generic data type , All languages know it .(json The essence of is string , It has nothing to do with other languages , It's just data types that can be converted to other languages with a little bit of processing , For example, it can be converted into Python Dictionary in ,key-value In the form of .)

3. What is the nature of the interface and how it works ?

You can simply understand the interface, which is to initiate a request to obtain response data , How it works URL adopt get perhaps post Request to send something to the server , Then we get some corresponding return values , The essence is the transmission and reception of data .

4. What is interface testing ?

Baidu Encyclopedia is summarized as : Interface test is a test to test the interface between system components .

The interface test is mainly used to detect the interaction points between the external system and the system as well as between the internal subsystems .

The focus of the test is to check the exchange of data , Transfer and control the management process , And the mutual logical dependence between systems .

To put it simply, through URL To servers or other modules etc , Transmit the data we want to transmit , Then see if the data they return is what they expect .

5. Why do interface tests ?

5.1 The lower you go, you find bug, The lower the cost of repair .

5.2 The front end changes at will , The interface has been tested , The back end doesn't have to change , The front and back end are developed by two groups of people .

5.3 Check the security of the system 、 stability , Front end parameters are not trusted , For example, e-commerce shopping system , The front-end price cannot be realized. The incoming data is -1 element , But through the interface, you can pass in -1 element .

5.4 Today's system complexity is increasing , The cost of traditional test method increases sharply and the efficiency of test decreases greatly , Interface testing can deal with test scenarios with high complexity , The higher the load, the better the interface test effect

5.5 Interface testing is relatively easy to automate continuous integration , And relative UI Automation is also relatively stable , It can reduce the labor cost and time of manual regression test , Shorten the test cycle , Support the demand of fast back-end publishing . Interface continuous integration is the source of low cost and high benefit .

5.6 Nowadays, many front and back architectures of systems are separated , In terms of security :

(1)、 Only relying on the front end to restrict can not meet the security requirements of the system ( It's too easy to get around the front ), The back end is also needed to control , In this case, it needs to be verified from the interface level .

(2)、 Front and rear transmission 、 Whether the information such as log printing is encrypted transmission also needs to be verified , Especially when it comes to users' privacy information , Such as ID card , Bank cards, etc .

6. How to do interface testing ?

Due to the separation of front and rear ends of most projects at present , The calling interface is mainly based on http Interface to protocol , So when testing the interface, it is mainly through tools or code simulation http Sending and receiving of requests . There are many tools like :postman、jmeter、soupUI、java+httpclient/TestNG、robotframework etc. .

– Interface automation can also be realized by code , The framework and UI Automation is almost , Send request to judge by assertion

7. What is the interface test point ?

Purpose : Test the correctness and stability of the interface ;

principle : Simulation client sends request message to server , After receiving the request message, the server processes the corresponding message and returns the response to the client , The process of receiving a response from the client ;

a key : Exchange of inspection data , Transfer and control the management process , It also includes the number of times to process ;

The core : Continuous integration is the core of interface testing ;

advantage : Bring efficient defect monitoring and quality supervision capabilities to highly complex platforms , The more complex the platform , The bigger the system , The more effective the interface test is ( Improve test efficiency , Enhance user experience , Reduce R & D costs );

Use case design focus : Usually, it mainly tests the outermost two types of interfaces : Data access system interface ( Call the parameters of the external system to use for the system ) Interface with data flow out system ( Verify whether the data processed by the system is normal );

PS: When designing use cases, you also need to pay attention to what functions external interfaces provide to external users who use these interfaces , What functions do external users really need .

8. For interface testing , Continuous integration interface automation is the core content , Interface automation includes the following :

8.1 In terms of process : In the regression stage, enhance the coverage of interface exception scenarios , And step by step test to the system , The smoke test phase extends , Finally achieve the whole process automation .

8.2 Result display : A richer display of results 、 Trend analysis , Test data statistics and analysis, etc

8.3 Problem location : Error message 、 More accurate logs , Facilitate the recurrence and positioning of problems .

8.4 Result verification : Strengthen the ability of automatic verification , Such as database information verification .

8.5 Code coverage : Constantly try to explore from the current black box to the white box , Improve code coverage .

8.6 Performance requirements : Perfect the performance test system , Monitor whether the interface performance indicators are normal by means of automation .

9. Interface test quality evaluation standard :

– Whether the business function coverage is complete

– Whether the business rule coverage is complete

– Parameter verification whether the requirements are met ( The border 、 Business rules )

– Whether the interface exception scenario coverage is complete

– Whether the interface coverage meets the requirements

– Whether the code coverage meets the requirements

– Whether the performance index meets the requirements

– Whether the safety indicators meet the requirements

When designing test cases, we mainly consider the following aspects :

01、 A functional test

Whether the function of the interface is implemented correctly

Whether the interface is implemented according to the design document

( such as username The parameters are written as user, So it's not in line with , Because the interface document needs to be used in the whole development , Therefore, the actual design of the interface should be consistent with the interface design document )

Compatibility test :
For example, the interface has been adjusted today , But the front end didn't change , At this time, it is necessary to verify whether the new interface meets the old call mode
Error code test :
Whether the general error code and business error code can clearly explain the call problem , Whether the error code can cover all situations as much as possible
Return value test :
The return value should be correct except for the content , It also needs to be the right type , Ensure that the caller gets these parameters and can parse them correctly

Parameter boundary value 、 Equivalence class testing

json Format testing :
Generally, our interfaces are designed to pass json strand , Then you need to test If non json The situation of , At this time, whether the program will correctly handle , Return to the corresponding error code
Default value test :
In many cases, some non mandatory parameters will have default values , For example, a query interface , Parameters count To return the number of results of the query , The default is 10, Then there should be one case To test , Of course, the precondition is that there must be such data in the database that exceeds 10 strip .

02、 Logic business

Whether there is a dependent business , For example, check the order , It requires users to log in first , So be sure to log in or have a corresponding cookie

Business logic testing : Pass the correct parameters , Interface to query the database operation , Need to verify that the database query is correct , Interface to the database Add, delete and modify operations , We also need to see whether the database has carried out these operations synchronously

03、 Abnormal test

Exceptions fall into two categories , Parameter exception and data exception

1、 Parameter exception :

Key parameters :
Write parameters as keywords in the development language
The parameter is empty. :
For example, remove it username Parameters
More or less parameters :
Verification of more or less parameters , It is still uncertain whether it is reasonable if an interface has more parameters and no error is reported , Or whether it needs to be optimized , Because the answer given by the current development is , Generally, the interface is not processed with more parameters
bad parameter :
For example, will username The parameters are written as user Wait and see if you can return to the corresponding error code

2、 Data exception :

Keyword data :
Fill in the value of the parameter as the keyword in the development language
Data is empty :
Fill in the value of the parameter
The length is not the same :
Because each field in the database has a field length , Fill in the non-conforming length for verification
Wrong data :
Is to fill in the value of the parameter arbitrarily , Or fill in non-existent values
Exception type test :
such as count Parameters , The type of this parameter must be convertible to int Type of , At this time, we need to test if some of the passes can't Convert to int Type value to test whether the code adds judgment

04、 Performance testing

response time
throughput
Number of concurrent users
Take up memory ,CPU etc.

05、 Safety test

Whether sensitive information is encrypted

Whether the necessary parameters are also checked in the back end

( Nowadays, many front and back architectures of systems are separated , In terms of security , Only relying on the front end to restrict can not meet the security requirements of the system ( It's too easy to get around the front end ), The back end is also needed to control , In this case, it needs to be verified from the interface level )

Whether the interface can prevent malicious requests (SQL Inject )

cookie:
take header Medium cookie Modify or delete to see if you can return the corresponding error code
header:
Delete or modify header The values of some parameters in , See if you can return the corresponding error code
Unique identification number :
Delete modify unique ID test

The house needs to be built layer by layer , Knowledge needs to be learned at one point one . We should lay a good foundation in the process of learning , More hands-on practice , Don't talk much , The last dry goods here ! I stayed up late to sort out the stages ( function 、 Interface 、 automation 、 performance 、 Test open ) Skills learning materials + Practical explanation , Very suitable for studying in private , It's much more efficient than self-study , Share with you .

Get off w/x/g/z/h: Software testing tips dao

Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .

原网站

版权声明
本文为[Software testing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060828356762.html