1.在实际开发中,开发android软件的过程需用不断的进行测试,使用Junit测试框架进行单元测试。
在清单文件AndroidManifest.xml中加入以下红色代码即可
<manifest xmlns:android=http://schemas.android.com/apk/res/android
package="cn.cbd.sms"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8“ android:targetSdkVersion="16" />
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="cn.cbd.sms" android:label="Tests for My App" />
<uses-permission android:name="android.permission.SEND_SMS"/>
<application android:allowBackup="true“ android:icon="@drawable/ic_launcher"
android:label="@string/app_name“ android:theme="@style/AppTheme" >
<uses-library android:name="android.test.runner"/>
<activity android:name="cn.cbd.sms.SmsActivity“ android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
targetPackage指的包要和应用package相同
2.建立测试类,该类一定要继承AndroidTestCase类.测试类的方法名建议以test开头.
3.编写单元测试代码.在方法上点击右键Run As -> Android Junit Test
转载于:https://blog.51cto.com/930307/1347774
351




被折叠的 条评论
为什么被折叠?



