1 AndroidManifest.xml的配置


1.1 使用单元测试库

   <uses-library android:name="android.test.runner" />,必须放在application内,同时在四大组件之前
   1.2 声明Android框架和目标测试库
 
 <instrumentation  android:name="android.test.InstrumentationTestRunner"  android:targetPackage="com.zhy.weather"  android:label="Android TestCase"  /> android:targetPackage="com.zhy.weather" android:targetPackage必须和<manifest package="com.zhy.weather">保持一致,
即android:targetPackage 的包名与manifest  的package相同就可以.

单元测试可以和应用不在同一个包下。

2 单元测试的方法
 
用作单元测试的方法要声明为public否则不能被调用到其方法原型为:public void 方法名() throws Exception {//do somthing}这里方法的名字可以不必以test开头注意:
3 AndroidManifest.xml文件详解(instrumentation)
                                         

语法(SYNTAX):

<instrumentationandroid:functionalTest=["true"|"false"] android:handleProfiling=["true"|"false"] android:icon="drawable resource" android:label="string resource" android:name="string" android:targetPackage="string"/>

被包含于(CONTAINED IN):

<manifest>

说明(DESCRIPTION):

这个元素声明了一个Instrumentation类,这个类能够监视应用程序跟系统的交互。Instrumentation对象会在应用的其他所有组件被实例化之前实例化。

属性(ATTRIBUTES):

android:functionalTest

这个属性用于指定Instrumentation类是否应该作为一个功能性的测试来运行,如果设置为true,这要运行,否则不应该运行。默认值是false。

android:handleProfiling

这个属性用于指定Instrumentation对象是否会开启和关闭分析功能。如果设置为true,那么由Instrumentation对象来决定分析功能的启动和终止时机,如果设置为false,则分析功能会持续到Instrumentation对象整个运行周期。如果设置为true,会使Instrumentation对象针对一组特定的操作来进行分析。默认值是false。

android:icon

这个属性用于给Instrumentation类设置一个图标。它必须要应用一个可绘制的资源。

android:label

这个属性用于给Instrumentation类设置一个用户可读的标签。这个标签可用原生字符串,也可以引用一个字符串资源。

android:name

这个属性用于设定Instrumentation子类的名称。应该是完整的Java类名(如:com.example.project.StringInstrumentation)。但是,也可以用简写方式(如:.StringInstrumentation),它的包名会使用<manifest>元素的package属性中指定的包名。

它没有默认值,必须被指定。

android:targetPackage

这个属性用于指定Instrumenttation对象所监视的应用程序。由包名所标识的应用程序会跟清单的<manifest>元素的package属性值相关联。

被引入版本(INTRODUCED IN):

API Level 1

更多相关文章

  1. Android中TextView:的ellipsize属性
  2. FAQ_15_android Imageview ImageButton Button
  3. 《Android面试宝典》学习笔记(第二章:布局)
  4. Android(安卓)RelativeLayout 属性
  5. Android之screenOrientation和configChanges使用和注意事项
  6. android:属性 layout_alignParentRight android:paddingRight
  7. Android之动画Animation的使用
  8. Android(安卓)众多的布局属性详解
  9. Android入门教程 sharedpreferences的用法

随机推荐

  1. Android(安卓)开源控件系列_2
  2. Android中自制通讯录中显示出数据库中的
  3. Android中的下拉列表-自定义选项界面样式
  4. ConstraintLayout子View设置match_parent
  5. Android(安卓)UI
  6. 如何卸载Eclipse中ArcGIS for Android的
  7. node.js+android http请求响应
  8. Android(安卓)获取sdcard音乐文件
  9. Android(安卓)XmlSerializer 换行
  10. Ubuntu 10.4下 Android(安卓)ADT的编译