first, the principle1.uiautomator--based on the UIAutomation user Interface Automation testing framework, can work across applications, Google biological.
UIAutomation a new version of Android4.3 when it was released, the official profile: http://blog.csdn.net/zhubaitian/article/details/40504827.
Before Android4.3: Use InputManager or earlier Windowsmanager to inject KeyEvent
After Android4.3: Use accessibility APIs to inject events. (Accessibilityservice has been doing some ancillary functions, providing a series of event callbacks that help us to indicate changes in the state of some users and interfaces, primarily to help people with disabilities.) )
2.robotium--a set of test frameworks developed based on instrumentation
Instrumentation's official profile: http://blog.csdn.net/zhubaitian/article/details/39578915
Instrumentation can load test packages and target test applications into the same process. Now that the controls and the test code are running in the same process, the test code can of course invoke the methods of the controls, while modifying and validating some of these controls.
How instrumentation works: Instrumentationtestrunner calls the OnCreate method to establish a new thread and adds a message queue to the thread before the target application code runs. This thread loops through and interacts with the message events that other lines Cheng over.
Cross-application: Android4.3 after instrumentation introduced an instance of the Getuiautomation interface for cross-application testing.
3.appium--cross-platform, allowing the same set of APIs to write test code on different platforms (ios,android), making it possible for test suites to implement code reuse on IOS and Android platforms.
The core of Appium is a network server that exposes the rest API. This server receives the client's connection, listens to the client's command, runs the command on the mobile device, and then sends the HTTP response packets that represents the result of the command back to the client.
second, advantages and disadvantages of comparison
|
uiautomator |
robotium |
Appium |
| Whether to support the device without source testing (black box test) |
Is |
Is |
Is |
| Can I perform cross-application testing |
Yes |
No |
Yes |
| Whether it is Google native |
Is |
No |
No |
| Support for programming languages |
Java |
Java |
Almost all languages |
| Question of whether there is a consistent signature |
Whether |
Is |
Whether |
| Do I need to solve Chinese input problem? |
Is |
Whether |
Is |
| Recommended additional control information for the development team |
Content Description |
Resource-id |
Content Description |
| Do I need API17 and above |
Is |
Whether |
Whether |
| JUnit supported version |
Junit4 |
Junit3 |
Junit3/junit4 |
| Whether to support WebView |
Whether |
Is |
Is |
| Support Platform |
Android |
Android |
Ios |
iii. Supplemental Content--android Three ways of injecting events
1, the use of internal APIs (internal API is Google does not open the code, there is a certain risk)
Access the Injectkeyevent/injectpointerevent two event injection methods by obtaining an instance of WindowManager.
Works properly within the app and does not work properly outside of the app (inject_events requires system permissions).
2, using the instrumentation object (open API, cleaner than the internal API) through an instance of instrumentation to access injectevent, the method of the above internal APIs.
So within the application can be normal work, in the application of external non-tender normal work.
3, direct injection of events to the device/dev/input/eventx
Linux exposes a unified set of event injection interface/dev/input/eventx (where x represents an integer) to the user in the form of a system device. We can call it directly.
Devices that require rooted, such as:
ADB shell
Su
chmod 666/dev/input/event3
Automated test framework comparisons (Uiautomator, Appium, Robotium)