1, Monkeyrunner: The advantages: The simplest operation, can record the test script, visual operation; Disadvantages: the main generating coordinates of the automated operation, the transplant is not strong, the most limited function;
2, Rubotium: Mainly for an apk for automated testing, APK can have the source code, also can not source code, powerful, the disadvantage is for the apk operation, and need to re-sign the APK (with tools), so the operation is relatively complex;
3, Uiautomator: The advantages: All operations can be automated, easy to operate; Disadvantage: Android version needs to be above 4.0, cannot operate according to the control ID, relative function is more limited, but also enough;
4, Monkey: Accurately speaking, this is not an automated test, because it can only produce random events, can not follow the established steps to operate;
From the above introduction can have this conclusion: Test an APK, you can choose Rubotium, the test process may involve multiple apk, choose Uiautomator; Some simple tests, choose Monkeyrunner;
|
Hierachyview+monkey |
Uiautomator + Monkey |
Robotium |
Permissions |
Root |
Ordinary |
Ordinary |
Whether a signature is required |
Is |
Whether |
Whether |
Response speed |
10s (user test data) |
4s (user test data) |
1-2s |
Whether to support WebView |
Whether |
Whether |
Is |
Whether to support cross-app testing |
Is |
Is |
Whether |
Android APIs that support this feature |
? |
API 16 |
API 7 |
Whether the control ID is supported |
Is |
Whether |
Is |
From the above data, Android provides testing tools have advantages and disadvantages, some support webview testing, and some do not support. Some support cross-application, some do not support. Therefore, a good Android test tool is more compatible with the above several test methods. For example, Appium.
The Uiautomator TestCase class inherits from the TestCase class of JUnit. The Robotium and espresso inherit from ActivityInstrumentationTestCase2. From this inheritance, we can also understand why the use of Robotium, the application needs to sign. The use of uiautomator is not required. The reason for this is: in a robotium way, the test code is essentially an APK. Depending on the security mechanism of Android, the application needs to be signed.
Android Automated test framework