Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to test API interface

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

The content of this article mainly focuses on how to test the API interface. The content of the article is clear and well-organized. It is very suitable for beginners to learn and is worth reading. Interested friends can follow the editor to read together. I hope you can get something through this article!

Back-end developers often ask, what do back-end interfaces test? How do you measure it? Briefly sort out the relevant contents of the interface test:

Test what? How do you measure it?

Currently, backend calls are mainly based on HTTP protocol, and there are two main methods for testing:

The tool simulates the sending and receiving of requests. There are many tools such as Postman, JMeter, etc.

The code simulates the sending and receiving of requests. For example, Webb, RestTemplete, HttpClient or others that come with JAVA

If it is a GET request, it is easier to put the URL directly into the browser.

II. Interface testing

What is an interface?

For example:

1. 12306 is a website, and all the data is on 12306. 12306 provides a whole set of interfaces, and we can get the data by calling the interface. For example, when you buy tickets on third parties such as Ctrip / eLong, you actually call the interface provided by 12306 to obtain inventory and other information.

2.Windows is a packaged system, according to reason, users do not have the right to do anything in Windows, but Windows provides a complete set of interfaces, calling interfaces we can operate Windows to do some behavior

Using the interface, we can operate on an encapsulated whole, including obtaining and manipulating data. The class library is a complete set of interfaces provided by the class library. Each method / function and other class members provided by the class library is each interface. The commonly written class also provides the interface. The class is the whole, and the member function of the class is the interface.

What is interface testing?

The simulation client sends a message request to the server, and after receiving the request message, the server processes the corresponding message and returns the reply to the client, and the client receives the reply.

Two main categories:

1. Code internal interface call, code An and code B in the combination, it is necessary to define some names and parameters, types, which are generally divided in the white-box test, testing the internal logic, there is no contact.

two。 The interaction between the system and the system is carried out through the transmission of network data, which is generally divided in the black box test, that is, the code can not be seen, but the network data can be sent to the interface by various means to get the response information of the interface to achieve the goal of testing.

This paper mainly describes the second kind of functional testing on the black box level, mainly the server interface.

[test ideas]

1. Single interface: there is no upstream and downstream dependency in the business scenario, and the function of an interface is directly a test module. In this case, you can test the interface directly from Construction parameters-> request-> Verification result

two。 Multiple interfaces: there is data flow between interfaces to form a completed business process, such as: a transaction process, including placing an order-> payment-> refund, etc. For this type of interface, you can consider covering it from the business scenario (familiarity with business is the foundation of automation)

[test data]

1. Manually construct data

If it is an interface that is only tested once, you can use manual data. For example, you need to test deal when testing the interface for issuing an order. You can manually order directly and write whatever data is used during the test.

two。 Call other API

You can directly prepare the test data by calling other API, for example, you need the order number when testing the refund and compensation API, and you can directly call the API to create the order type you want.

3. Automated tools construct data

[test tools]

You can choose Postman, Jmeter, etc.

Thank you for your reading. I believe you have a certain understanding of "how to test the API interface". Go and practice it. If you want to know more about it, you can follow the website! The editor will continue to bring you better articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report