当前位置: 代码迷 >> Android >> Android测试框架一(非原创)
  详细解决方案

Android测试框架一(非原创)

热度:87   发布时间:2016-04-24 12:01:29.0
Android测试框架1(非原创)

1.继承AndroidTestCase :public class JunitTest3 extends AndroidTestCase {}

2.在AndroidManifest.xml清单文件中添加如下代码:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.showdata"
android:versionCode="1"
android:versionName="1.0" >


<instrumentation
  android:name="android.test.InstrumentationTestRunner"
  android:targetPackage="com.example.showdata" >
</instrumentation>

<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="com.example.showdata.MainActivity"
    android:label="@string/app_name" >
    <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>

 

3.在要测试的方法上右击-->Run As --->Android Junit Test、需要先打开模拟器

 

  相关解决方案