A mobile testing black technology based on dynamic plug-in system

Source: Internet
Author: User

Baidu MTC is the industry's leading mobile application testing Service platform, providing solutions to the cost, technology and efficiency issues faced by developers in mobile application testing. At the same time share the industry's leading Baidu technology, the author from Baidu employees and industry leaders and so on.

This article Hyxbiao && Tony Xin

Background

Mobile app plug-in is platform-based product solution system limitations (65535), module decoupling, and multi-team collaboration tool. Its biggest feature is the dynamic release of the module, the benefits to the product is obvious, but, in Baidu, this system to mobile testing technology brings new ideas

Several scenarios for problem locating on the moving tip:

    • Scenario One: The Cloud user feedback a feature is not available, RD guessing several possible causes, the online collection of client-side logging information is not complete, unable to fully confirm the problem. Trapped in a dead loop, online users continue to expose the problem, the offline can not be stably reproduced, can not locate the problem in time. How to break?

    • Scenario two: Through the client-side embedding method of user behavior, often there will be a problem of point-of-care, and often the location of the problem on the line needs these behavior logs for the problem location to provide good replication steps. How do I get full user-client interaction logs without coding and technical means?

    • Scenario Three: Offline a lot of good tools can be SDK, to the online problem discovery and positioning brings a lot of positive benefits, but because the test capability itself will affect the performance of integrated apps, or development team scheduling and other reasons, can not be integrated, a large number of online problems can not be fully exposed. How to gracefully solve this problem?

    • 4:100-degree on-line client small flow experiments show that the online problem is actually a normal distribution of random events, top problem, often only a small number of users can recall, and do not need to affect the full amount of users

Several scenarios for testing under moving tip:

    • Scenario One: Client-side testing is simple but complex, and a simple skill tree for a client tester might include the ability to analyze these problems: ANR, crash, stutter, memory leaks, memory, CPU usage, power analysis, startup speed analysis, and a range of skills. And often, some QA personnel are not full stack. And the use of these tools itself, is a large collection of tools. How to get a client tester, or a non-professional tester, without any background, with the ability to have all the client-side problem analysis in a single point

    • Scene two: With just said the line problem positioning, offline a large number of excellent features, and can not be applied to the full amount of users, because they are hurting the enemy 800, self-inflicted 1000 of the ability. How to minimize the user experience loss, let the problem as far as possible all recall?

A new approach to problem location on moving tip:

Based on the plug-in system, do a test plug-in, all of us feel useful in the offline testing ability to enter, while integrating the industry well-known good framework, such as dexposed, leakcanary, and some systems open but the main version of the use will affect the performance of good things traceviewer, Choreographer, Activitylifecyclecallback and so on. All hit the cloud plug-in, and through the cloud has been built dynamic module small flow system issued to a specific target user mobile phone, continuous exposure problems

Nice job!!

how the Cloud plugin works :
The cloud plug-in itself is the host of a plug-in, the real ability to play its test capabilities, the offline construction of a large number of test scenarios, and the plug-in itself dynamic loading mechanism, so that our test scenario can play its effectiveness online. Mention this will have to fry the old rice in a new pot:

    • Parental delegation mechanism: Under the Java class-loading mechanism, the sub-ClassLoader can look up the loaded content of the parent ClassLoader, thus providing a prerequisite for the cloud plug-in to dynamically find the host's various classes of information (a multi-process plug-in system). Please ignore me)

    • Dexclassloader: Any jar (containing Dex files), zip, apk file that can load the file system

    • Patchclassloader: can only load data/app/apk files, often used for multi-dex split projects

    • Dexfile: The dynamic file can be loaded, while extracting the class information inside the file, this is Dexclassloader does not have

    • Shell: The Cloud Plugin's own scenario requires an integrated information upload class, but at compile time, the corresponding class cannot be compiled into a plug-in package. When the scene plugin is loaded, it can callback the host's log system for information collection.

The scene plugin, which is wrapped in a jar or APK, can be dynamically loaded by the cloud plugin, while reading and capturing the host's various classes, local space, and host-related information in the system. As for hooks, reflections, code injection, anomaly capture, piles, etc. these are just a means.

Instance:

Note : The following case, although the cloud plug-in problem location scenario, but not only the cloud plug-in, we will be in the form of SDK open source This part of the technology, so the integration of the SDK app can also do so, but away from the plug-in system, its own security, Developers who need integration are focused on their security. Of course, you can not pay attention to the root of the mobile phone, your app itself has been all exposed to the hacker (BLESS ...)

Text: In the case of fluency, let's look at how to build the Cloud debug plugin very quickly.

Fluency : It can be understood that the speed of drawing UI for Android system, in theory, the human eye in 1s to receive 60 frames of images to feel the program smooth. At the beginning of the Android system, fluency has been the object of criticism until the Android 4.1 system, with the annotated project Buffer and the introduction of three major elements, VSYNC (vertical sync), Triple Buffer, and choreographer. Which choreographer this thing is the goal we are discussing today. It is the coordinator of the entire mechanism, and all Looper share a choreographer object

Choreographer to open up a framecallback thing, in each system drawing, will pass this callback Doframe function, through this function can calculate in 1s, the current page drawing times. But here's the problem:
Look, the meaning is, this goods although good, but the suggestion is you developer or not to use ... This How to play, originally also want to take it last smoothness monitor. At this point it will be thought that we have a cloud debugging plugin.

The build is very simple, as follows, only need to copy this code to any Android project, and then packaging, note that Nutxerror only as a compilation dependency, if there is a plug-in system, this code can be directly loaded and run the

PublicClass
NutframemonitorExtendsBaseCase {
PrivateStaticFinal String TAG ="Nutframemonitor";
@Override
PublicvoidInvoke(Context context) {
int sdkversion =0;
try {
Sdkversion = Build.VERSION.SDK_INT;
}catch (Exception e) {
Todo
}
if (sdkversion >=16) {
try {
Choreographer.getinstance (). Postframecallback (Nutframecallback.callback);
}catch (Exception e) {
Todo
}
}
}

PrivateStaticClassNutframecallbackImplementsChoreographer.Framecallback {

StaticFinal Nutframecallback callback =New Nutframecallback ();
PrivateLong Mlastframetimenanos =0;
PrivateLong Mframeintervalnanos = (Long) (500000000)-1;
@Override
PublicvoidDoframe(Long Frametimenanos) {
if (Mlastframetimenanos! =0) {
FinalLong Jitternanos = Frametimenanos-mlastframetimenanos;
if (Jitternanos > Mframeintervalnanos) {
Nutxerror error = new Nutxerror (TAG);
error.setdetailmessage ("frame choreographer waste more than 500ms");
Error.dump ();
}
}
Mlastframetimenanos = Frametimenanos;

Choreographer.getinstance (). Postframecallback (Nutframecallback.callback);
}
}

}
Results

This is the time when the operation client is running (note that the monitor case is dynamically loaded via the cloud plugin) and finds a smoothness problem. At the same time, you can see that after the monitoring to the drawing problem, the user stays in each interface is also drawn out. And then you can follow this trace to reproduce the result.
Isn't it cool ~ ~

Postscript

As above, it ended the technical discussion on the mobile testing of Baidu. However, there are a lot of not mentioned, such as the existing automated case has been built, and how compatibility of this mechanism, and so on, such as sharp-eyed students will also find that the system itself may have compatibility issues, how to do a problem card control, to ensure that the cloud debugging plug-in (in fact, we call the nut cloud) effective and timely recovery. In fact, we have plenty of confidence to try this thing online. In the factory line, we have a set of dynamic module small flow system, the cloud plug-in itself is actually used as a dynamic module, when there is a problem on the line, our cloud plug-in will play its value

For more dry foods, please pay attention to "Baidu MTC Academy" Http://mtc.baidu.com/academy/article

A mobile testing black technology based on dynamic plug-in system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.