• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
小咖博客
博客园    首页    新随笔    联系   管理    订阅  订阅

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、需要先打开模拟器

 

posted @ 2015-12-23 08:39  小咖博客  阅读(214)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3