Unit test learning for Android

Source: Internet
Author: User

1. unit test concept

Unit testing (also known as Module Testing) is used to test the correctness of program modules (the smallest unit of software design ).ProgramA section written by a memberCode. For object-oriented programming, the smallest unit is the method, including the methods in the base class (superclass), Abstract class, or derived class (subclass.

The test framework in Android is extended.Junit3So before learning unit testing for Android, You can first learn how to use junit3. there are not many things to learn about junit3.

For more information about junit3, see http://android.blog.51cto.com/268543/49994.

Document: http://wenku.baidu.com/view/87a176abd1f34693daef3e54.html

Related classes involved in the unit test of Android:

Activityinstrumentationtestcase: you do not need to consider this type for the first test.

Activityinstrumentationtestcase2: This class is mainly used to test the function of the activity and the Interaction test of the activity. For example, the jump of the activity and the interaction between the UI. The most I use is this class.

Singlelaunchactivitytestcase: This test case only calls setup () and teardown () once. Unlike other test cases, every time a test method is called, setup () is re-called () and teardown (). therefore, this class is used to test whether the activity can correctly process multiple calls.

Activityunittestcase: Mainly used to test the activity. Because it allows injection of mockcontext and mockapplicaton, you can test the activity in different resources and applications.

For more information, see the SDK documentation Dev guide and API reference.

2. Android unit test related classes

Is the UML diagram of the test-related classes in Android:

3. case:

See http://yuanzhifei89.iteye.com/blog/1122104

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.