Interface automation testing - tools, requests and responses

1. Tools:

1. Tool introduction

postman: It is a very mainstream API testing tool, and it is also the most widely used R&D tool in the work.

JMeter:

ApiPost:

2. Install postman:

Open it directly after installation, no need to register.

2. Communication mode:

1. Synchronous communication:

The client requests the server to have a response, and other operations cannot be performed before the response. If there is a defect, it will cause queuing, waiting, and congestion.

When there are too many tasks, the server is under too much pressure, which may cause a crash. In order to prevent crashes, thread pool technology is needed. Our current software uses this technology.

Thread pool technology: (All requests are tasks, and each task is a thread) The thread pool specifies the maximum number of tasks to be executed at the same time. (For example, the server specifies a maximum number of tasks of 90, and the client sends 100 tasks, and the remaining 10 tasks adopt a queue mechanism (first-in-first-out principle))

queue : Queue (first in first out principle)

2. Asynchronous communication:

The client sends data (commodity name, price) to the mq message queue, the server obtains the data from the mq message queue, responds to the mq message queue (deduction is successful), and the mq message queue responds to the client (payment is successful)

Mainstream MQ message middleware:

Kafka、RabbitMQ、ActiveMQ

Apache is an open source web server from the Apache Software Foundation

Kafka is mainly used in the field of big data and is excellent in real-time streaming data, capable of processing quadrillions of data

RabbitMQ is mainly used in general services and has high requirements for data consistency, reliability, and security.

 

现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

3. Request and response

1. Grab network requests in web pages

Take JD.com as an example: Right-click to check→Network→Refresh→ www.jd.com

2. The client sends a Request to the server:

2.1 Function:

The protocol used when the client (app, browser) sends a request to the server - http request protocol.

Specifies the syntax format of data transfers sent to the server.

2.2 Format:

1、请求方法
2、请求地址:(url:http协议+域名+资源路径)
3、请求头:  Key:Value格式
        User-Agent:描述请求发送端的浏览器类型
        Content-Type:描述请求参数的数据类型 (json数据格式;form表单数据;xml)
     referer:
     cookie:
4、请求参数
    post和put大部分有请求参数(在postman中有请求参数的方法需要在请求头中添加类型,在请求体中选择类型)
    get和delete大部分没有请求参数

Introduction of postman: (According to the interface document, the simulated client sends a request to the server)

3. Request method:

There are 8 commonly used request methods, the most commonly used are 4-5:

GET request method: get resource

POST request method: add resources (you can also modify and delete existing resources on the server)

PUT: modify resource

DELETE: delete resource

OPTIONS: route map

3.1 GET request method: get resources

Example 1:

Step 1: Open JD.com, find a picture type pgn in the obtained data, get the request address and copy it to postman to use:

Step 2: Select the GET method in postman, paste the obtained address, and click send to get the picture:

GET request parameters:

query params

Step 1 : Obtain the method and address in the interface document: (protocol plus the domain name in the second line plus the resource path in the first line)

Step 2 : Select the GET method in postman, copy the address, click send, and the request parameter (KEY) will automatically appear, and we will fill it in (the VALUE part of the figure below)

(The request parameters of the GET method are written in Params in postman)

3.2 POST request method: add resources (you can also modify and delete existing resources on the server)

请求方法:
请求地址:
请求头:
    表现形式为key-value的形式
    在请求头中关注”Content-Type“来获取请求参数的类型,如:
        json数据格式:application/json        
        表单格式:application/x-www-form-urlencoded
        XML数据格式:text/xml
请求参数:
  (在postman请求体中选择数据类型时:form格式直接选择x-www-form-urlencoded,xml和json格式需要先点raw再选)

Step 1: Obtain in the interface document: request method; request address (add protocol to the address); obtain the request parameter type in the request header; specific request parameters:

Analyze the interface document to summarize the obtained content:

Method: POST

Request header:

Data format: Content-Type: text/xml; charset=utf-8

Request parameters:

<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> soap:Body <getMobileCodeInfo xmlns="http://WebXml.com.cn/"> <mobileCode>string</mobileCode> <userID>string</userID> </getMobileCodeInfo> /soap:Body /soap:Envelope

Step 2: Open the postman tool:

1. Select the request method

2. Paste the request address (add http protocol in front)

3. Click on the request header Headers

4. Click Body, select the type of data obtained (directly select x-www-form-urlencoded for form format, click raw before selecting for xml and json format) select the data type of response, and fill in specific request parameters

Example 2:

Step 1: Obtain the request address, request method, request data type, and specific request parameters:

Step 2: Select the method in postman, fill in the address (fill in the protocol http), add the data type in the request header, select the parameter type in the request body, and paste the parameters

2.3.3 PUT: modify resource

2.3.4 DELETE: delete resources

2.3.5 OPTIONS: route mapping

3. The server responds to the client:

3.1 Function:

On the server side, for the http request sent by the client, send back the response data - http response

Specifies the data organization format sent back to the client

3.2 Format:

1. Protocol status code

2. Response header (key: value)

Content-Type: Describes the data type in the response body

3. Response data (most of them are not empty. Successful request: send back data, failure: send back error message)

4. Response time (note) :

It refers to the sum of the time sent by the client plus the time it takes the server to respond to the client's request. in milliseconds.

The size of the response data is in kb.

The following are supporting learning materials. For friends who do [software testing], it should be the most comprehensive and complete preparation warehouse. This warehouse also accompanied me through the most difficult journey. I hope it can help you too!

Software testing interview applet

The software test question bank maxed out by millions of people! ! ! Who is who knows! ! ! The most comprehensive quiz mini program on the whole network, you can use your mobile phone to do the quizzes, on the subway or on the bus, roll it up!

The following interview question sections are covered:

1. Basic theory of software testing, 2. web, app, interface function testing, 3. network, 4. database, 5. linux

6. web, app, interface automation, 7. performance testing, 8. programming basics, 9. hr interview questions, 10. open test questions, 11. security testing, 12. computer basics

Information acquisition method:

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/132605247