单元测试

1、清单文件配置

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 3     package="com.example.junit"
 4     android:versionCode="1"
 5     android:versionName="1.0" >
 6     <!-- 指令集 -->
 7     <instrumentation 
 8         android:name="android.test.InstrumentationTestRunner"
 9         android:targetPackage="com.example.junit"
10         />
11     <uses-sdk
12         android:minSdkVersion="8"
13         android:targetSdkVersion="19" />
14 
15     <application
16         android:allowBackup="true"
17         android:icon="@drawable/ic_launcher"
18         android:label="@string/app_name"
19         android:theme="@style/AppTheme" >
20         <!-- 使用的库函数 -->
21         <uses-library android:name="android.test.runner"/>
22         <activity
23             android:name="com.example.junit.MainActivity"
24             android:label="@string/app_name" >
25             <intent-filter>
26                 <action android:name="android.intent.action.MAIN" />
27 
28                 <category android:name="android.intent.category.LAUNCHER" />
29             </intent-filter>
30         </activity>
31     </application>
32 
33 </manifest>

2、要继承AndroidTestCase类

3、实现的单元测试方法要注意抛出异常throws Exception

posted @ 2016-04-13 10:40  zhongyinghe  阅读(105)  评论(0)    收藏  举报