当前位置:网站首页>How many tips do you know about using mock technology to help improve test efficiency?
How many tips do you know about using mock technology to help improve test efficiency?
2022-07-28 21:53:00 【Yehna rahmin】
Mock What is it? ?
Let me describe these scenes for you , See if you are familiar ?
Test a business module , Several interfaces in this business module are connected to the third party , Because the third party delayed delivery , Lead to project delay , I'm carrying the pot again
I want to test whether the front-end page fonts are compatible , Need to change the database of related fields , But I have no permission to modify the database , I'm so worried
The leader asked me to test the software deployed on a certain machine , But ... The machines are not deployed , There is no way to test
The module I tested is seriously coupled with other modules , Other modules have not been developed yet , I can only wait , The final test was delayed … Performance hit again C 了
These are in our usual testing process , Often encountered problems blocking the progress of testing , What are the technical means , Can solve these problems , Improve our testing efficiency ?
Don't worry about knowing the answer , You can take a look at the above four processes , In fact, it is our tested module that is moving to a certain dependent environment ( Third party service 、 Back end interface 、 Hardware device 、 Other services ) In the process of sending the request , There is a problem with the dependent environment , This will affect our testing efficiency .
So if we put this “ dragging ” Directly replace the dependent environment of , Change to our own service interface , We can return whatever we want it to return , Test it , Is it much easier ?

The scene above , Actually used , That's what we're going to teach you next Mock technology .
How to use Mock technology ?
Mock There are many ways to achieve this , Can pass mitmproxy+python Realize deep customization Mock, It can also be done through fiddler or Charles This relatively simple tool implements some basic Mock.
First , Let's first see how to pass Charles Realization Mock. Before implementation , Just a quick introduction Charles This tool .Charles Itself is a very powerful agent tool , Charles The main functions include :
Support SSL agent . Can grab analysis https Request .
Support flow control . Can simulate slow network and waiting time (latency) Longer request .
Support retransmission of network requests , Convenient for backend debugging .
Support modifying network request parameters .
Support network request interception and dynamic modification .
Can automatically put json or xml Formatting Data , Convenient view .
Yes, of course , The focus of this article is on Mock technology , Then let's take a look ,Charles How to achieve Mock . .
adopt Mock The effect of technology modifying Baidu page
1. Save the data returned by the interface first , Right click an interface -> Click on SaveResponse -> Write the file suffix .html



2. To the local html Make changes , take “ use Baidu Search ” Change it to “ Hogwarts ”


3. Set up Charles Conduct map local, Right click on the Map Local-> Get into Edit Mapping -> Click on choose -> Select the modified html-> Click on OK



4. At this time, ask Baidu again , You can see “ use Baidu Search ” Change into “ Hogwarts ”


adopt Mock Technology modifies the display effect of stocks
The above case is Mock An application scenario with relatively simple technology , that Mock Whether technology can be used in App The same effect is achieved in application ? For example, below , We are going to test whether the list display color of the snowball stock interface will change with the rise and fall limit of the stock price .

Maybe here , Many students said , You can change the database , But there may be two problems in changing the database :
1、 Not all tests have the right to modify the database .
2、 Some data information is obtained directly from the third-party interface , The test cannot have the permission to change the third-party service database .
In fact, it is very simple to realize the above test requirements , Just make good use of Mock Tools , understand Mock Implementation and configuration principle of , You can easily complete the list display of the snowball stock interface, and whether the color will change with the rise and fall limit of the stock price , So as to improve the test efficiency .

summary
Of course , The above small exercises are only realized Mock A simple application scenario in technology , As for how to solve the dependence of third-party services and other more Mock Use scenarios of Technology , And more advanced how to combine Mock Technology realizes a data factory , You can come to our 《3 Training camp for automated test of sky interface 》 Try to understand ~
边栏推荐
- Pytorch学习记录(四):过拟合、卷积神经网络CNN
- 微星宝安工厂失火!官方回应:无人员受伤,产线不受影响!
- 聊一聊数据库的行存与列存
- Record some small requirements in the form of cases
- What technology is needed for applet development
- 二 RedisTemplate的序列和反序列化机制讲解
- World Hepatitis Day | grassroots can also enjoy the three a resources. How can the smart medical system solve the "difficulty of seeing a doctor"?
- JVM 内存布局详解(荣耀典藏版)
- 作价11.5亿元,1206件设备注入合资公司!SK海力士抢食大陆晶圆代工市场!
- Mysql的B+树高度计算
猜你喜欢

技术选型Rust——事后分析

Data interpolation -- normalize data of different magnitude

中国科学家首次用DNA构造卷积人工神经网络,可完成32类分子模式识别任务,或用于生物标志物信号分析和诊断

JVM 内存布局详解(荣耀典藏版)

Research on the recognition method of move function information of scientific paper abstract based on paragraph Bert CRF

Chinese patent keyword extraction based on LSTM and logistic regression

基于BRNN的政务APP评论端到端方面级情感分析方法

开放式耳机哪个音质好、公认音质好的气传导耳机推荐

基于知识元的外文专利文献知识描述框架

基于属性词补全的武器装备属性抽取研究
随机推荐
Huawei releases the first electric drive system driveone: charging for 10 minutes, endurance of 200km
Meeting notice of OA project (Query & whether to attend the meeting & feedback details)
【Bluetooth蓝牙开发】八、BLE协议之传输层
Implementation of sequence table
The Swedish court lifted the 5g spectrum auction ban on Huawei and ZTE
微星宝安工厂失火!官方回应:无人员受伤,产线不受影响!
关于一些小需求,用案例方式记录
[极客大挑战 2019]Secret File&文件包含常用伪协议以及姿势
Explain C language 12 in detail (C language series)
面向千元级5G手机市场,联发科天玑700发布
Versailles ceiling: "the monthly salary of two years after graduation is only 35K, which is really unpromising ~ ~"
Chinese patent keyword extraction based on LSTM and logistic regression
Leetcode linked list problem -- 142. circular linked list II (learn the linked list by one question and one article)
30. Learn highcharts label rotation histogram
开放式耳机哪个音质好、公认音质好的气传导耳机推荐
[Bluetooth Bluetooth development] VIII. Transmission layer of ble protocol
微信小程序开发入门,自己开发小程序
Edited by vimtutor
LeetCode链表问题——面试题02.07.链表相交(一题一文学会链表)
节省70%的显存,训练速度提高2倍!浙大&阿里提出在线卷积重新参数化OREPA,代码已开源!(CVPR 2022 )



