Charles uses summary for MacOS

Source: Internet
Author: User
Tags ssl certificate

Recent tests often use Charles's mock data as a small white, summarizing the problems encountered in the personal use process and facilitating further learning and understanding.

First, install the configuration Charles Agent

1, the official website downloads the latest version of Charles and Charles.jar;

2, set the Mobile Terminal (Android&ios) HTTP proxy;

3, install the PC and mobile SSL certificate, in order to crawl HTTPS messages, PS: Sometimes Android and iOS installation certificate can not catch HTTPS, need to check whether the certificate trust;

4. Enter Charles and start grabbing the bag.

Ii. Charles use Case (breakpoint function)

1, in testing the app front and back data interaction, only need to view the front-end display according to the backend interface, you can modify the return message mock data to test the front-end display, Note that the specific business logic also requires front-end configuration testing .

2. In order to improve the efficiency of the mock data, we can copy the request or the JSON data returned to the text editor in advance, and then the mock front end according to the key field of the interface document (if it is necessary to know the meaning of each interface field and the corresponding request return).

3, set breakpoints, can be mock request and return, according to individual test needs.

4, after the test can save the previous mock of the different JSON text, the subsequent test can be directly modified to use.

5, check the interface if the expected mock results are not present, you first need to check that the modified fields are correct, such as: Modify order status and Statusname, and statusnameopelag, you need to understand the logical mapping of three fields.

Iii. summarizing Charles ' use of the experience

Interface Test points: 1, the front-end simulation of various types of input, to ensure the quality of the interface Layer 2, due to the current many front and rear ends are separated, so the front and rear end can not trust each other 3, check the interface return data is consistent with the expected results 4, check the fault tolerance of the interface four, Charles use question 1, Solutions to garbled Chinese: add-dfile.encoding=utf-8 in Charles ' Content/info.plist vmoption

2, the development of the Android app is HTTP requests, and then changed to HTTPS, there is the following situation, can not read the content of the crawl

Workaround:

(1) Check whether the mobile certificate is installed

PS: Installation method Step no longer cumbersome, you can own Baidu method ha

(2) The iOS installation is successful or the unknown is displayed

WORKAROUND: Set the general "about this machine" certificate trust settings (this at the bottom) tick enable full trust for root certificates and enter Charles again, provided that the agent for the server and the client must be set up.

(3) Add a breakpoint using Charles asynchronous request two interfaces

(4) Modify the status code to return different result sets

    • 1. Successful Login
      {"code": "000000","data": {由于涉及到业务信息,部分data信息隐藏"status": "0"},"msg": "成功"}
    • 2. Operation Timeout
{    "code": "030801",    "msg": "操作超时"}
    • 3. The log-in system is busy
{"code": "000001","msg": "系统繁忙,请稍后再试!"}
    • 4. Login timeout
{"code": "000002","msg": "登录超时!"}
    • 5. Log out of the line
{"code": "000004","msg": "账户在另一台设备已登录,当前登录被挤下线!"}

 

Charles uses summary for MacOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.