How can I develop Android systems/applications without understanding automated testing?

Source: Internet
Author: User

I have been in touch with andorid for several months. I have always thought that as a system, application development does not need to understand Android automated testing. I think that is what testers need to know. As long as we understand development, you only need to understand the system and make corresponding changes according to the customer's needs. As long as you are familiar with the API, you can write an application to implement a certain function. Actually not.

For example, if our great client is crazy about changing hardware configurations, then our drivers will be switched back and forth, and the C implementations of related functions will also be changed, the upper-layer Java corresponds to a slight modification, and the customers who are tired of the problem have a bad demand, so there is only good luck ...... Fortunately, the whole process is complete. Google promptly released a high version of Android, and customers were about to upgrade it. At this time, they suddenly found that the system they modified was not just optimized and added the XX function as compared with the native Android system. The four words were as bad as they were. At this time, the perfect upgrade is almost equivalent to rewriting. It is actually very easy to avoid this tragedy, that is, after completing the development task, use CTS to test compliance with the android compatibility specifications. If all the pass items are OK, we are very grateful. If there are fail items (which do not affect system compilation and implementation of related functions, but do not comply with the compatibility specifications), you should check the relevant files in time and do not modify them, return the implementation to Android. If it is really difficult, we should say hello to the customer in advance to avoid being thrown back by them in the future.

Android automated testing is not just CTS, but also monkey, ase, robotium, and instrumentationd... are all very practical tools. For example, in the UI test of an application and in a single activity test, instrumentationd is the greatest hero.

 

 

What does Android. Test provide for us?

 

 

 

 

Here is an example to boast of activityinstrumentationtestcase2 <t extends activity>

 

Public t getactivity () {</P> <p> activity A = super. getactivity (); </P> <p> if (a = NULL) {</P> <p> // set initial touch mode </P> <p> getinstrumentation (). setintouchmode (minitialtouchmode); </P> <p> final string targetpackage = getinstrumentation (). gettargetcontext (). getpackagename (); </P> <p> // inject custom intent, if provided </P> <p> If (mactivityintent = NULL) {</P> <p> A = launchactivity (targetpackage, mactivityclass, null ); </P> <p >}else {</P> <p> A = launchactivitywithintent (targetpackage, mactivityclass, mactivityintent ); </P> <p >}</P> <p> setactivity (a); </P> <p >}</P> <p> return (t) a; </P> <p >}</P> <p>

 

 

 

With getactivity (), you can easily obtain the activity and use the methods to avoid the problem that the object cannot be instantiated and some methods cannot be used. Before get,setActivityIntent(Intent)And/orsetActivityInitialTouchMode(boolean), Provide custom setup values to your activity.

 

 

Recently, I have been dealing with the camera and solved several bugs. After testing the CTS, I accidentally found that the hardware test of the camera was a non-compliant fail item in the CTS, all are passed. So I was excited. Why didn't I start looking for a bug exit for the CTS results? This goal was quickly locked and the solution efficiency was doubled.

 

To put it simply, CTS

$ Make CTS // After compiling the android source code, compile the cts

Decompress the android-cts.zip generated in step 1 and then perform the test. For detailed operations, you can search for more information on the Internet.

The CTS test will automatically generate the corresponding test package, which is located in the following directory:
Android-CTS/Repository/results
Each test package contains the following files;
Cts_result.css
Cts_result.xsl
Logo.gif
Newrule-green.png
Testresult. xml
The test results of this package are all in the testresult. xml file. You can see from the file that these packages are compatible with Android.

 

Note that the CTS is constantly updated as the Android version is updated.

If you are curious, you can try it. You can test the same device on the same system using cts of different versions from R1 to R5, with unexpected results!


 

If you do not understand the test, do not say that you are a good developer. In particular, Android provides us with a convenient automated testing mechanism. What's the reason.

Author: yiyaaixuexi published on 1:02:00 Original article link reading: 526 comments: 12 Views comments

Related Article

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.