Interface packet capture analysis and mock combat

insert image description here


1. Summary of knowledge points

How to locate whether the bug is generated by the front end or the back end?
How to obtain interface information when there is no interface document?

1. Capabilities required for interface packet capture

Proxy function: HTTP/HTTPs, SOCKS5.
Request simulation tool: assembly request, replay request, repeat request.
Network environment simulation: speed limit, timeout, return exception.
Mock: request modification, response modification.
Fake: Replace the real environment with a test environment.

2. The principle of interface packet capture

insert image description here

2. Basic use of Charles

Tool preparation

Charles installation
Basic computer configuration and certificate configuration completed
Mumu emulator packet capture configuration completed

Reference post: https://ceshiren.com/t/topic/21956

Three, charles packet capture analysis

Grab interface data

Overview: The general situation of the interface
Content: Request information and response information
The first half: request, request header information, request parameters, cookie
The second half: response, response header information, response body (different formats)

Summary: Response time
Chart: Resource status display in icon form
Notes: Write some records
insert image description here

Fourth, Charles uses

1. Filtering: Filter, Focus

insert image description here

2. Repeat: Repeat, Repeat Advanced

insert image description here

3. Modification request: Compose

insert image description here

4、弱网:Throttle Settings

insert image description here

5. Web packet capture practice

Grab snowball search interface data
insert image description here
When there are multiple interfaces, you can use ctrl+f to find a specific interface, as shown in the figure below

insert image description here

insert image description here

View the interface response status code and the protocol version used
insert image description here

View request parameters and response content in json format
insert image description here

Edit the request parameters, replace the search content with your own name, resend the request, and view the response content
insert image description here

Interface to quickly filter snowball domain names
insert image description here

6. App packet capture practice

Grab snowball search interface data
insert image description here

View request parameters and response content in json format
insert image description here

Set resend 10 times, the number of concurrency is 2, and the delay time is 500ms
insert image description here
insert image description here

Perform a weak network test, select the weak network mode as 256 kbps

insert image description here

7. Mock test

1. What is mock test

In test activities, for some more complex data/scenes that are not easy to construct or obtain, a virtual object (Mock object) is used to create a test method for testing.
insert image description here

2. The value and scenarios of mock testing

Value:
No reliance on third-party data.
Save work.
Save joint debugging.

Scenario:
front-end and back-end data interaction.
Third-party system data interaction.
Decoupling of hardware devices.
Boundary value testing.

insert image description here

3. Use Charles to complete the Mock test

Rewrite: Dynamically modify the data in the request and response; suitable for global modification or simple modification of content
Map Local: Complex modification of the response body Map
Remote: Modify the address of the server to be accessed; in App testing, you can directly modify without repackaging test environment

Use the interface of Snowball Quotes Preferences – stock price reminder list.
Rewrite:
Change the first stock name in the list to your own name.
Change the ticker symbol of the second stock in the list to hogwarts.

4. Rewrite practice

Use the snowball to set the interface of the hot stock list.
Rewrite:
Change the name of the first hot stock in the list to your own name.
Change the name of the second hot stock in the list to another name.

insert image description here
insert image description here

insert image description here
insert image description here
Match all requests ending with .json, as shown in the figure below
insert image description here
insert image description here
insert image description here

5. Map Local practice

Use Snowball to set up the interface of hot news list.
insert image description here

Map Local:
Change the name of the first hot stock in the list to your own name.
Change the name of the second hot stock in the list to another name.

1. Select the interface to be mocked, right mouse button, save Response, modify the response data

2. Right-click the mouse, select Map Local, enter the setting interface, automatically fill in the data related to the interface url, and select the local data of the target

insert image description here

3. Tools——Map Local, double-click the rule to enter the modification interface, check the enable function to take effect

insert image description here

4. New responsive page

insert image description here

6. Map Remote practice

Use Baidu search interface.
Map Remote:
Redirect the interface to the Sogou interface.
Baidu will display a warning pop-up window, pay attention to the interface data captured in Charles

insert image description here

1. Select the interface to be mocked, right mouse button, and select Map Remote;

2. Enter the setting interface, automatically fill in the relevant data of the interface url, select the local data of the target, and fill in the url information of the server to be forwarded

insert image description here

3. Tools——Map Local, double-click the rule to enter the modification interface, check the enable function to take effect

insert image description here

4. New responsive page

insert image description here

Guess you like

Origin blog.csdn.net/YZL40514131/article/details/131049768