This article was first published on Zhihu
An overview of the
APP compatibility testing mostly takes the generic approach of randomizing operations within the APP. The Android Monkey tool is still widely used by developers due to its simplicity and convenience. However, some drawbacks of native Monkey come to light as it is used on a large scale.
advantages | Simple and convenient a command can be used, stable test; A large number of operational events can be sent per second, and the pressure is high enough that problems can often be found that would not be found with normal use |
---|---|
disadvantages | The testing process is not controllable, and we often click on the controls and interfaces we do not want to click on, such as randomly clicking system Settings, closing developers, etc. Coverage of all controls in app may not be satisfactory in unit time; The test process information cannot be recorded. As a result, the process and cause of the problem cannot be analyzed after the problem is discovered |
The shortcomings of native Monkey lead to uncontrollable test performance and efficiency. What can be done to fix these problems? Rock Mouse has made more explorations in this aspect and developed the “intelligent traversal tool”, which uses UI automation to acquire the controls of the APP and carry out a random and controllable traversal to cover all interfaces and controls in the tested APP as far as possible.
Framework Technical Solution
Monkey traversal tools based on UI automation fall into the following two categories
Technical solution | Based on Macaca or Appium to do the driver, on the PC side to achieve traversal calculation method for testing | The traversal algorithm is tested on Android mobile phone based on Uiautomator driver |
---|---|---|
On behalf of | Appcrawler, Macaca’s own NoSmoke | Maxim |
advantages | 1. Don’t focus too much on drivers, leverage existing UI automation frameworks 2. The test result data is easy to save on the PC |
1. Use Uiautomator to execute monkey easily and quickly, with good compatibility 2. Higher test efficiency and stability |
disadvantages | More dependent frame, less efficient and less stable | Test results can be too large to save on the phone |
From the above comparison, it can be seen that the Uiautomator mode directly runs on the mobile terminal, which is more convenient for deployment and execution, and has better efficiency and stability. So the rock rat chose this plan for modification. Of course, there is also a problem that Uiautomator is officially no longer maintained and has been replaced by Uiautomator2. Frameworks like mainstream Appium are also developed based on Uiautomator2. However, even the latest version of Android Q can still use Uiautomator, and the API is basically enough for Monkey traversal. Compared with Uiautomator2, the advantage of Uiautomator is that it does not need to install APK and can push JAR to the mobile end to execute directly, avoiding the problem that all frameworks like Uiautomator2 need to install two additional APKs, especially OPPO. Vivo and other mobile phones need to install the password caused by the success rate of installation. The advantage of Uiautomator2 is the continuous support of the subsequent official. More and better apis can be used to obtain the application context so as to achieve more functions of Android services. Rock Rat is currently evolving to use Uiautomator2 to drive tests.
Traverse the technical solution
Control traversal scheme is the most core part. Of course, the only goal is to cover all the controls and functions of the APP as much as possible, and to execute as much code as possible. However, the traversal process may encounter many problems, such as:
- How do I explore all the actionable controls and access all the activities to be tested?
- How to improve the efficiency of traversal, avoid control too many repeated operations?
- How do we block operations we don’t want?
- How do we limit our testing to what we want?
- How to solve the login problem?
- How to evaluate the effectiveness of the test?
- How can I help you later reproduce the problem?
All the problems, including but not limited to the above, may be encountered in the process of realizing controllable Monkey. At present, there is not a unified perfect solution, but more improvement and perfection in practice.
Intelligent traversal algorithm
Intelligent traversal process
Evaluate the effectiveness of intelligent traversal
For the analysis of traversal effect, the rock Mouse intelligent traversal tool provides the analysis of click coverage at the Activity level to know which activities have been visited and the corresponding click times. This can be viewed on the Rock Rat report page.
The future direction
- Optimize the algorithm to improve the traversal coverage and efficiency of APP controls
- Establish traversal effect evaluation system
- AI algorithm is introduced to achieve more intelligent traversal
Welcome to the
Rock mouse cloud real machine and compatibility testing services are limited free experience, welcome to try and exchange! Yanshu.effirst.com/ Long click to identify the TWO-DIMENSIONAL code, pay attention to us, more product information, technology dry goods to share