Preface:
First, we first define a concept, what is the interface, what is called interface testing ?
application programming interface is also called API ", software mechanism
Interface Test is a test of the interface between components of a test system. Interface testing is primarily used to detect the interaction points between external systems and systems, as well as within each subsystem. The focus of testing is to examine the exchange of data, the transfer and control of management processes, and the mutual logical dependencies between systems.
(This chapter does not speak postman, jmeter and other tools, directly into the straight road, the tool is dependent after all)
1. Pre-Preparation1.1. Preparation Tools:
1, Python3.7 + notepad (Windows comes with the Text Document tool) | (Linux with VI edit can also)
2. Request Library: Or install Lib library via pip command:
PIP Install requests
3, Urllib.request (no installation, the program comes with library | Python 2.7 Library named: urllib)
1.2. Example Interface Description:
Demo interface: Watercress movie Search
Document Description: Https://developers.douban.com/wiki/?title=movie_v2#search
API request Address: Https://api.douban.com/v2/movie/search?
1. Search by Name: API request address + q= Iron Man
2. Search By Type: API Request address + tag= Comedy
Description: In the actual work of the interface to explain the development will be delivered to our hands, do not worry.
1.3, Interface Casing:
1, get the API do not worry about testing, through the manual point can be normal use
2, write the corresponding test cases, such as the top test by the film name and type of search: (demo)
testdemo1:https://api.douban.com/v2/movie/search?q= Iron Man Testdemo2:https://api.douban.com/v2/movie/ search?q= comedy Testdemo3:https://api.douban.com/v2/movie/search?q= dinosaur horror film Testdemo4:https:// api.douban.com/v2/movie/search?q=
2. Interface Authoring (I will communicate with the interface by using two Python libraries) 2.1. Urllib initiated the request:
Import"tomcruise"# Tom Cruise's movie "https:// Api.douban.com/v2/movie/search? " # originating request via Urllib HTML = Html.read (). Decode ("utf-8" )print(HTML)
2.2. Requests initiated the request:
Import"tomcruise"# Tom Cruise's movie "https:// Api.douban.com/v2/movie/search? " # launch request via requests print(req)
2.2, requests initiated the request: 2.2, requests initiated the request:
"Not yet finished, update in ~ ~ ~"
Your first interface test: a Python interface test