1.测试类继承AndroidTestCase
2.在文件Manifest.xml中加
<uses-library android:name="android.test.runner"/>
这个节点与activity同级,
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.zjr.android.test"
android:label="test"
></instrumentation>
与application同级
android:targetPackage 与manifest中的package同样,修改test类所在的包
1 <?xml version="1.0" encoding="utf-8"?> 2 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 package="com.zjr.android.test" 4 android:versionCode="1" 5 android:versionName="1.0"> 6 <uses-sdk android:minSdkVersion="10" /> 7 8 <application android:icon="@drawable/icon" android:label="@string/app_name"> 9 <uses-library android:name="android.test.runner"/> 10 <activity android:name=".TestDemoActivity" 11 android:label="@string/app_name"> 12 <intent-filter> 13 <action android:name="android.intent.action.MAIN" /> 14 <category android:name="android.intent.category.LAUNCHER" /> 15 </intent-filter> 16 </activity> 17 18 </application> 19 <instrumentation 20 android:name="android.test.InstrumentationTestRunner" 21 android:targetPackage="com.zjr.android.test" 22 android:label="test" 23 ></instrumentation> 24 </manifest>