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