Study Notes-Interface Test (postman, jmeter)

1. What is interface testing?
Interface testing usually refers to the external interface of the system. For example, if you need to obtain or synchronize resources and information from other systems, they will provide you with a written interface method for you to call. For example, commonly used apps need to be called through interfaces when users synchronize and process data.

The webService interface and the http api interface are the two most common interface methods. The latter is the most commonly used. It uses the http protocol and has get and post request methods. The returned data is json type. Interface testing can also be said to be functional testing. By calling the interface Get data from the database and return it.

2. Front-end and back
-end If the front-end and back-end are said to be client and server, it is easier to understand. Open a web page on a browser, open a management system, and operate on an APP. These all belong to the front end, and its role is Displaying the page, operating the page, and processing these business logic functions such as non-empty verification on the page, business logic functions can all be implemented through the backend, and the interaction between the frontend and the backend is through the interface.

3. The difference between get request and post request.
The request data of the get request interface is placed in the URL, while the request data of the post request interface is placed in the body. The get request can be accessed directly in the browser, while the post request can only Done with tools

4. Cookie and session
Cookie is a key-value pair stored locally, corresponding to key-value, and session is a key-value pair kv stored on the server.

5. Basis for interface testing:
Interface specification document, which at least includes

1. Interface description 

2. Call url

3. Request method (get\post)

4. Request parameters, parameter types, request parameter descriptions 

5. Return parameter description 

6. HTTP status code
Every http request sent will return a status code to identify whether the request is successful. Common status codes include the following:

1) 200 2 indicates that the request is successful.

2) 300 3 means the focus is on

3) 400 4 indicates that the request sent by the client has a syntax error.

4) 500 5 means the server is abnormal.

7. Common interface use cases

8. postman interface test

1) get request

    Request parameters can be passed directly after the url. Use the & symbol for multiple parameters, url?x=x&xx=xx

    header is used to transmit some additional information

For example: interface for obtaining student information, screenshot of postman test operation

Get all student information interface to add header information, postman test operation screenshot

2) post request

 For example, the login interface contains content: post request method, request url, fill in the parameters in the body, and click send to return the data.

 Add student information interface (the input parameter is json type), including content, request url, post request, parameters, select raw in the body and fill in the json string

 Student gold coin information recharge interface, including permission authentication, which requires the addition of administrator permission cookies. The operation content includes the request URL, select Headers to add cookies, and body to add parameters.

 Get all student information interface, add header information, operate content, request url, add Referer to header

File upload interface

9. Jmeter interface test
1) Is the result tree garbled in jmeter?

Go to the bin directory of jmeter's installation directory and find jmeter.properties, add sampleresult.default.encoding=utf-8

Restart jmeter

2) How to solve the problem of garbled characters in jmeter body data?

Go to the bin directory of jmeter's installation directory and find jmeter.properties and add jsyntaxtextarea.font.family=Hack

Restart jmeter

3) jmeter parameterization

    User-defined variable 
        thread group-"Add-"Configuration component-"User-defined variable, add name, value, reference variable fill in ${variable name}

   Function assistant
       options - "Function assistant dialog box, select the function function, such as __random, __time, click [Generate] after selection, copy the generated function string to the request data, __time generates a timestamp, and the timestamp is How many seconds have passed since the day the computer was born? If you want to convert to other date formats, fill in the value in the function assistant box and then generate

   File reading
       thread group-》Add-》Configuration component-》CSV Data Set config

 4) jmeter pressure measurement indicators

Thread Group-Add-Aggregation Report shows the number of concurrent users, response time (the faster, the better), and tps (the number of requests processed by the server per second, the bigger the better).

5) Use JSON Path PostProcessor association to obtain return information

Install the JSON Path PostProcessor plug
-in Request-》Add-》Post-processor-》SON Path PostProcessor
extracts according to the corresponding data in the returned json parameter. For example, the k value corresponding to sign is login_info, which is $.login_info.sign

 6) Steps to operate the database

1. Install mysql-connector-java-5.1.7-bin.jar and put it in the lib directory of the jmeter installation directory.

2. Test plan-browse and add mysql-connector-java-5.1.7-bin.jar

3. Thread Group-Add-Configuration Component-JDBC Connection Configuration, fill in the database connection

4. Thread group-add-sampler-JDBC Request

Select the operation type. For queries, select statement is limited to a single query. If there are multiple queries, you can choose Callable Statement (no format required). But except for the last sql, other sql needs to be ended with;. For insert statements, choose Callable Statement.

 

Guess you like

Origin blog.csdn.net/qq_73332379/article/details/133133332