Interface Test:

Brief introduction

  Often hear people say that interface testing, test automation interfaces, but you have to interfaces, the number of knowledge and understanding to know what is the interface do? It is used to do the testing time to pay attention to what? Frankly, before I was not very clear. Then look at the definition of the interface.

definition 

       Refers to entities provide their own interfaces to the outside of one kind of abstraction thereof (may be another entity), methods for separating the internal and external communication operations, that it can be modified without affecting the way inside the external interact with other entities.

  The interface between human and computer information such as a machine or a human with a user interface program is called. Interface called hardware interface between computers and other information on the machine hardware components. Interface called software interfaces between computers and other information equipment software components.

  In the computer, the interface is a computer system sharing two separate components boundary information exchange. This exchange may occur between the personal computer hardware and software, operating an external device or may be a combination thereof.

Advantages interface

  A normative

  Interface is standardized throughout the system design, involving many layers, each layer in order to make clear calls between words, you only need to know the interface, according to this specific interfaces do what you do, it can be integrated into the overall system.

  Life examples of the many, for example: plugs, sockets, standard specification should tell you plug a few feet, sockets are a few holes, etc., do plugs, sockets companies to do is plug in accordance with this specification, sockets, and We do not need to finish a plug traveled around the world to try to do the right plug.

  Second, scalability

  In the project development process, due to the constantly changing needs of customers, if the interface is not used, then we have to keep rewriting the existing business code. Rewrite the code may generate new BUG, ​​and rewrite the code will affect the business of calling the class, you may need to modify all, affect the stability of the system itself. In the end, the code may appear messy and difficult to read,

  After taking over the people can not read the code, the system increasingly heavy maintenance work may eventually lead to failure of the project.

  Third, the interface is a project business logic, interface-oriented programming is first extracted out of the customer's business, as the interface. Business accomplished by implementing the specific implementation of the interface class. When changes in customer demand, just write a new class that implements the business logic does not need to rewrite existing code, reducing the impact on the system. So that the project has a greater scalability.

Common Interface Type

  It refers to the interface between the point of interaction between the external system and the internal subsystems and systems. Including external interfaces, internal interfaces, internal interfaces and includes: the upper and lower service service interface, similar interface.

  Common web interface: one is the interface http protocol, and the other is a web service interfaces (such as soup, rmi, rpc protocol). This paper describes the http request interface.

  Common ways including http request: get (check), post (increase), in addition to put (change), delete (delete) and so on. Daily work to see the most is get and post two kinds.

   GET: GET can be said to be the most common, and its essence is to send a request to get a server to a resource on. Resources through a set of HTTP headers and present data (such as HTML text or pictures or video, etc.) back to the client. GET request, it will never contain rendered data.

   POST: submit data to the server. This method is widely used, almost all of the current commit operation is completed by this. It is used to submit data processing request to the designated resource (e.g.: submission form and upload files), the data packet is contained in the request body, may result in the modification POST request to create a new resource or the available resources.

   PUT: This method is relatively rare. HTML forms do not support this. Essentially, PUT and POST are very similar, are sending data to the server, but there is an important difference between them, PUT usually specifies where resources, but there is no POST, POST data storage location is determined by the server itself. Data transfer client to the server to replace the contents of the specified document.

   For example: URL as a submission for Bowen, / addBlog. If PUT, URL will then be submitted is like "/ addBlog / abc123 ", where abc123 is this blog address. If using POST, then the address of the server will tell the client after submission. At present, most are like this blog. Obviously, PUT and POST use is not the same. Specific use which also depends on the current business scenario.

  DELETE: delete a resource. Basically this is also very rare, but still there are some places such as amazon 's S3 cloud service which will use this method to delete the resource.

1) get Interface

Format: write requests to the URL parameter, connection, use multiple parameters "&" connection "?." Such as: https:? //Api.douban.com/v2/book/search q = '', which is a development of watercress query api book information, q = '', in single quotes is to query parameters, such as Query " little Prince 'book information, q =' little Prince ', to use the tool to test postman, as shown below:

 

 

Scene: get type interface is used to obtain information, and more for query data, such as a list of queries, click the query button to get a call to the interface, and then return the information out

Features: 1) a small amount of request data, 2) exposed to the url parameter address, so there is a security risk

2) post-type connector

Note: Please submit data (such as submitting a form, upload a file) to a request to specify the resource position, post requests may lead to the creation of new resources

Scene: such as registration, uploading, posting and other functions, such as user in a book collection of watercress website, write notes, comments

Features: request data capacity, safety

Such as watercress comment open api, see below:

 

 

3) put Interface Type

Description: put a request for uploading content to the latest specified resource location

Scene: As users modify the collection for a particular book in the watercress website, modify or amend an article notes Comments

Such as modifying the comment watercress open api, see below:

 

 

4) delete type Interface

Description: Delete requested resource request to the server identified in the url

Scene: If the user cancels the collection of a book in the watercress website, delete a chapter notes or delete comments

Such as deleting comments watercress open api, see below:

 

No common interface types (to understand)

    Unusual http request method includes: head, connect, options and trace.

    head:HEAD和GET本质是一样的,区别在于HEAD不含有呈现数据,而仅仅是HTTP头信息。换句话说,就是返回响应中没有具体内容,只获取报头。有的人可能觉得这个方法没什么用,其实不是这样的。想象一个业务情景:欲判断某个资源是否存在,我们通常使用GET,但这里用HEAD则意义更加明确。

    connect:HTTP/1.1协议中预留给能够将连接改为管道方式的代理服务器。

    options:这个方法很有趣,但极少使用。它用于获取当前URL所支持的方法。若请求成功,则它会在HTTP头中包含一个名为“Allow”的头,值是所支持的方法,如“GET, POST”。允许客户端查看服务器的性能。

    trace:回显服务器收到的请求,主要用于测试和诊断。

附录(get和post的区别)

这个问题,面试中经常被提到。简单来说,可以从三个方面去回到这个区别:方式、大小、安全

1).方式

方式指的是参数的传入方式,GET方法一般是指获取服务器上的数据,参数直接跟着URL后边,直接可以放到浏览器地址栏里,例如登录就是采用GET方法。而POST方法是指客户端给服务器上提交表单数据,所以POST是通过表单提交的,例如你网页上的新用户的注册、调查问卷和答题就是采用POST方法。

2).大小

上面已经知道GET是直接在浏览器地址栏输入,由于浏览器有限制,一般整个URL的长度可以很长,但是不能超过2049KB的大小限制,而这个POST就没有大小限制。

3).安全性

由于GET的参数是在浏览器地址栏直接拼接,暴露在互联网中,肯定不安全。POST是通过表单数据提交,相对比GET方法更安全。

Guess you like

Origin www.cnblogs.com/zhang-da/p/12046805.html
Recommended