当前位置:网站首页>Technology Sharing | How to simulate real usage scenarios?mock technology to help you

Technology Sharing | How to simulate real usage scenarios?mock technology to help you

2022-08-09 09:58:00 Tester_muller

Mock is a tool that modifies requests and responses through proxies to assist in constructing more application scenarios.For example, at work, it may be necessary to mock third-party callbacks to the tester's testing environment, so as to carry out the test work more smoothly and make the test environment closer to the real usage scenario.

Charles Modification Request and Response

MapLocal

Redirect the specified network request to a local file.

1. First save the data returned by the interface, right-click an interface -> click SaveResponse -> select html format

2. Modify the local html and change "Baidu Yiyi" to "Hogwarts"

3. Set charles to map local, right click on Map Local-> enter Edit Mapping -> click choose -> select the modified html-> click OK

4. At this time, if you request Baidu again, you can see that "Baidu" has changed to "Hogwarts"

In the Charles menu, select Tools->Map Remote or Map Local to enter the setting page of the corresponding function.

MapRemote

is to redirect the specified network request to another URL request address.

  1. Set parameters Toos->Map Remote
  1. Check the access results, you will find that www.baidu.com will be redirected to www.sougou.com

Rewrite function

The Rewrite function is suitable for some regular replacement of a certain type of network request to achieve the purpose of modifying the result.

  1. Open Tools->Rewrite, replace the content, and replace "My Concerns" in the page with Hogwarts
  1. Apply to Baidu again, again, "My Concern" has become "Hogwarts"
原网站

版权声明
本文为[Tester_muller]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/221/202208090943259309.html