当前位置:网站首页>Software Testing Technology: cross platform mobile UI automated testing (Part 2)
Software Testing Technology: cross platform mobile UI automated testing (Part 2)
2022-07-26 22:08:00 【Learning leader】
3、 Use JavaScript The engine executes the code :JavaScript Engine selection
iOS You can use the system's own JavaScriptCore Framework implementation .Android Can be used in Rhino As an execution engine ,Rhino It's a use Java language-written JavaScript Open source implementation , Originally by Mozilla Development , Now integrated into JDK 6.0. Of course, you can choose Chrome Of V8 The engine performs , choice Rhino The reason for the engine is that it uses Java Language writing , You can use jar Integrate into the project in the form of packages .
4.1、JavaScript call Native The end plug-in executes the command :JavaScript and Native Terminal communication method
If you use WebView To display the web page , You can use WebView The characteristics of JavaScript and Native End ( Unification index iOS and Android End ) signal communication . But directly use JavaScript When the engine , Can't use shouldOverrideUrlLoading() And other methods to intercept specific instructions , also Native Code and JavaScript Different scopes , Objects cannot be shared with each other , Therefore, we cannot call each other directly . In this case , The engineer is in JavaScript Memory space to maintain an instruction queue , whenever JavaScript Need to call Native Code , Push the instruction into the instruction queue ,Native The client takes an instruction from the instruction queue to execute , After execution , Check whether there is a next instruction in the instruction queue to continue execution , Until all instructions are executed .
4.2、JavaScript call Native The end plug-in executes the command :JavaScript and Native End communication protocol
JavaScript Every instruction in the instruction queue , Include the plug-in name 、 The goal is 、 Parameter three parts .
Native After receiving the plug-in name , Find in advance Native Plug ins registered on the client , Pass in details “ The goal is ” and “ Parameters ” To execute .
Each instruction can be written in “ The plug-in name :// The goal is ? Parameters ” In the form of .
For example, it is often used in test code perform_event plug-in unit :
The above instructions represent execution Native Terminal “ Click... On the interface 7 Daily annualized yield ” The user action .
5.1、 Run the test business according to the instructions :Native The client uses plug-ins to execute instructions
Native A series of plug-ins need to be registered when the client starts , for example perform_event The plug-in represents the execution of user actions ,snapshot Representative screenshot . Because the plug-in is implemented in Native End , So we should implement it according to the characteristics of the platform , for example “perform_event://client?text=7 Daily annualized yield ” This Directive , stay iOS End can be derived from UIViewController Of View Start , Look down for UILabel, See if there are items that contain specific text , Then click on the item . And in the Android End , have access to solo This test framework is used to directly click on specific text parts on the screen .
Use code to simulate user behavior , For example, open “ Buy ” page , You can click “ Buy ” Button (perform_event://client?text=7 Daily annualized yield ), You can also directly launch the purchase page (open:// Purchase page ). In order to simulate user behavior more truly , It is suggested to simulate the real behavior of users as much as possible during the test , Don't skip user actions and achieve results directly , For example, in the previous example, it is suggested to start from all View Found in with “ Buy ” Text buttons , Realize button click operation .
5.2、 Run the test business according to the instructions : Test data preparation
In the test, from Native The client requested REST API Simulated test data must be used , To ensure the consistency of page data at any time .
On the one hand, analog data can be used in Native End pass Mock One HTTP Server To cut off all HTTP request , But it also needs iOS and Android Both platforms are written , Two parts of data need to be maintained in the future . A better way is to build a simulation directly on the test server REST API service , For each test case , Return fixed analog data , If the data is simple , Using static JSON File can .
6、 Data collection and comparison
The image after the screenshot is directly in Native End pass HTTP Upload the protocol to the server . On the server side , By phone model 、 operating system 、 Operating system version 、 Business name 、 Number, classify and save , In this way, you can quickly find all screenshots of a business on a device . Save all recorded data in the test server , Every time the test screenshot is collected from the test equipment , Compare pixels with the recorded data on the server , Then return the test results to the mobile terminal Unit Test Case.
3、 ... and 、 summary
Through the above methods , Complete the integration test of one module at a time , Engineers will write complete test code , And record screenshots of the test object on all devices . Any future modifications , The complete regression test of the whole system will be carried out on all test equipment , Pixel level comparison can ensure that all pages of the system 、 Every pixel 、 There is no change on every device , It greatly saves the time of regression testing .
Through server-side unified deployment , There is no need for iOS and Android Writing test code at both ends . And used for testing JavaScript in , You only need to write interactive instructions for user operation , It greatly reduces the technical requirements and time cost of writing test code .
When the system becomes increasingly complex 、 More and more developers 、 When the number of models that need to be adapted continues to increase , This cross platform automation UI test , It can effectively ensure the quality of the mobile terminal , After all, a mobile terminal is fatal bug, You may need to upgrade the version 、 App store Review 、 The long process of end-user update can be solved , And this process will lead to the loss of users .
Of course , Automated testing can only be used as an aid to manual testing , Finish work that is not suitable for human , Proactively finding problems in the first round of testing is not the strength of automated testing , Even if you can find , Also have to pay more costs . Rapid and massive regression testing is what automated systems are good at .
There is no silver bullet in the test , Improve people's subjective initiative 、 Avoid formal constraints 、 Use automation technology to replace mechanical labor , The road to continuously improve the quality of system delivery will never end .
Source of the article : The Internet The copyright belongs to the original author
The above is not for commercial purposes , If it involves intellectual property , Please contact Xiaobian , We will deal with it immediately
边栏推荐
- 09 expr 命令
- Try new functions | decrypt Doris complex data type array
- A friend with a monthly salary of 50000 told me that you were just doing chores
- Dream weaving prompt dedecms error:tag disabled:php!
- 【Try to Hack】防火墙(一)
- What to do if the browser home page is tampered with, and how to recover if the home page is tampered with
- Go----Go 语言中的标识符和关键字
- The principle of normal equation method and its difference from gradient descent method
- xshell7个人免费下载,使用
- 同花顺上面开户安全吗,开户怎么选券商
猜你喜欢

开发转测试:从零开始的6年自动化之路

TASK04|分类分析

Development to testing: a six-year road to automation from scratch

JDBC summary

Pytoch uses RNN model to build person name classifier

Can I view the history in the "stealth" mode of the secure browser?

Thoroughly understand the principle and implementation of service discovery
![[mysql]substr usage - query the value of specific digits of a field in the table](/img/d5/68658ff15f204dc97abfe7c9e6b354.png)
[mysql]substr usage - query the value of specific digits of a field in the table

matlab 画短时能量图

伦敦银外汇走势理解与实操
随机推荐
Altium Designer 22 修改选中元件的层属性
正则表达式及绕过案例
Let Xiaobai thoroughly understand performance tuning
easyui datagrid 获取多条选中的数据进行操作
仅需一个依赖给Swagger换上新皮肤,既简单又炫酷~
Matlab draws short-term average amplitude spectrum
Overview of MPLS Basics
仅需一个依赖给Swagger换上新皮肤,既简单又炫酷
[RequireComponent(typeof(....))]
Try new functions | decrypt Doris complex data type array
C# 数据类型_摘自菜鸟教程
Go --- identifiers and keywords in go language
LDAP -- realize unified login management of users
Isilon 的OneFs常见操作命令(一)
软件测试技术之跨平台的移动端UI自动化测试(下)
The principle of normal equation method and its difference from gradient descent method
JDBC summary
Go ---- variable usage in go language
Matlab draw short-term energy diagram
Pytorch 使用RNN模型构建人名分类器