当前位置:网站首页>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 ~
边栏推荐
- MSI Bao'an factory is on fire! Official response: no one was injured, and the production line will not be affected!
- Storage and steps of phospholipid coupled antibody / protein Kit
- 华为发布首款电驱动系统DriveONE:充电10分钟续航200km
- 8、 QoS queue scheduling and message discarding
- Nano gold coupled antibody / protein Kit (20nm, 1mg/100 μ g/500 μ G coupling amount) preparation
- Discussion: if you want to land Devops, is it enough to only consider a good PAAS container platform?
- 小程序开发需要什么技术
- Wechat applet development company, do you know how to choose?
- Information fusion method and application of expert opinion and trust in large group emergency decision-making based on complex network
- 基于属性词补全的武器装备属性抽取研究
猜你喜欢

磷脂偶联抗体/蛋白试剂盒的存储与步骤

Adventures of little mouse: behind the scenes gags of moss 2

LT7911D Type-C/DP转mipi 方案成熟可提供技术支持

Divide and conquer, upload large files in pieces

Matlab|基础知识总结一

Vimtutor编辑

LeetCode链表问题——面试题02.07.链表相交(一题一文学会链表)

微信小程序开发公司你懂得选择吗?

节省70%的显存,训练速度提高2倍!浙大&阿里提出在线卷积重新参数化OREPA,代码已开源!(CVPR 2022 )

Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future
随机推荐
JVM 内存布局详解(荣耀典藏版)
基于知识元的外文专利文献知识描述框架
The general strike of three factories in St France may make the shortage of chips more serious!
酷派主动终止针对小米公司的专利侵权诉讼
C process control statement
技术选型Rust——事后分析
基于Xception-TD的中华传统刺绣分类模型构建
1945. sum of digits after string conversion
Record some small requirements in the form of cases
Storage and steps of phospholipid coupled antibody / protein Kit
Leetcode 142. circular linked list II [knowledge points: speed pointer, hash table]
C语言入门【详细】
MySQL
How is nanoid faster and more secure than UUID implemented? (glory Collection Edition)
I have been in the industry for 4 years and changed jobs twice. I have understood the field of software testing~
Divide and conquer, upload large files in pieces
An end-to-end aspect level emotion analysis method for government app reviews based on brnn
Matlab | basic knowledge summary I
Library borrowing system "suggested collection"
Bully is filed for bankruptcy! The company has become a "Lao Lai", and the legal person is restricted from high consumption



