InstrumentationTestRunner 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
This class is obsoleted in this android platform
Instrumentation针对 Android 包(应用程序)运行各种类型的 junit.framework.TestCases。
[Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)]
[System.Obsolete("This class is obsoleted in this android platform")]
public class InstrumentationTestRunner : Android.App.Instrumentation
[<Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)>]
[<System.Obsolete("This class is obsoleted in this android platform")>]
type InstrumentationTestRunner = class
inherit Instrumentation
- 继承
- 特性
注解
Instrumentation针对 Android 包(应用程序)运行各种类型的 junit.framework.TestCases。
<div class=“special reference”><h3>Developer Guides</h3>
有关应用程序测试的详细信息,请阅读 测试 开发人员指南。
</div>
<h3>典型用法</h3><ol><li>Write junit.framework.TestCases,用于针对包中的类执行单元、功能或性能测试。 通常,这些是从:<ul><li>android.test.ActivityInstrumentationTestCase2</li><>android.test.ActivityUnitTestCase</><>android.test.AndroidTestCase<><>android.test.ApplicationTestCase<li/li/><>android.test.InstrumentationTestCase<li/><>android.test.ProviderTestCase<><>android.test.ServiceTestCase<li/><>android.test.SingleLaunchActivityTestCase<li/li></ul><li>Set the android:targetPackage attribute <instrumentation> of the element in the test package's manifest. 应将属性值设置为正在测试的目标应用程序的包名称。
<li>使用“adb shell am instrumentation -w”(没有可选参数)运行检测,以运行所有测试(性能测试除外)。
<li>使用“adb shell am instrumentation -w”运行检测,并将参数“-e func true”用于运行所有功能测试。 这些测试派生自 android.test.InstrumentationTestCase.
<li>使用“adb shell am instrumentation -w”运行检测,参数“-e unit true”运行所有单元测试。 这些测试 不派生自 android.test.InstrumentationTestCase (不是性能测试)。
<li>使用“adb shell am instrumentation -w”运行检测,并将参数“-e 类”设置为运行个人 junit.framework.TestCase。
</ol><p/>运行所有测试: adb shell am instrumentation -w com.android.foo/android.test.InstrumentationTestRunner <p/>Running all small tests: adb shell am instrumentation -w -e size small com.android.foo/android.test.InstrumentationTestRunner <p/>Running all medium tests: adb shell am instrumentation -w -e size medium com.android.foo/android.test.InstrumentationTestRunner <p/>Running all large tests: adb shell am instruments -w -e size large com.android.foo/android.test.InstrumentationTestRunner <p/>Filter test run to test with given annotation: adb shell am instrumentation -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner <p/> If used with other options, the resulting test run will contain the union of the two options. 例如,“-e 大小大 -e 批注 com.android.foo.MyAnnotation”将仅运行包含 LargeTest “com.android.foo.MyAnnotation”批注的测试。
<p/><b>筛选器测试运行到没有给定注释的测试:</b> adb shell am instrumentation -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner <p/>Running a single testcase: adb shell am instrumentation -w -e class com.android.foo.Foo/android.test.InstrumentationTestRunner <p/>Running a single test:adb shell am instrumentation -w -e class com.android.foo.FooTest#testFoo com.android.foo/android.test.InstrumentationTestRunner <p/>Running multiple tests: adb shell am instrumentation -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner <p/>Running all tests in a java package: adb shell am instrumentation -w -e package com.android.foo.subpkg com.android.foo/android.test.InstrumentationTestRunner <p/>包括性能测试:adb shell am instrumentation -w -e perf true com.android.foo/android.test.InstrumentationTestRunner <p/To debug your tests, set a break point in your code and pass: -e debug true <p/>>To run in 'log only' mode -e log true. 可用于快速获取检测命令要执行的测试的信息。
<p/>若要生成 EMMA 代码覆盖率:-e 覆盖率 为 true 注意:这需要 emma 检测生成。 默认情况下,代码覆盖率结果文件将保存在 /data/<app>/coverage.ec 文件中,除非由 coverageFile 标志重写(请参阅下文) <p/> 若要指定 EMMA 代码覆盖率结果文件路径: -e coverageFile /sdcard/myFile.ec <br/> 以及其他参数。
此成员已弃用。 请改用 AndroidJUnitRunner 。 应使用 Android 测试支持库编写新测试。
Java文档android.test.InstrumentationTestRunner。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。
构造函数
| 名称 | 说明 |
|---|---|
| InstrumentationTestRunner() |
已过时.
初始化 InstrumentationTestRunner 类的新实例。 |
| InstrumentationTestRunner(IntPtr, JniHandleOwnership) |
已过时.
创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。 |
字段
| 名称 | 说明 |
|---|---|
| ReportKeyIdentifier |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态或最终捆绑包中,则此键标识正在写入报告的类。 (继承自 Instrumentation) |
| ReportKeyNameClass |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态或最终捆绑包中,则此键标识当前测试类的名称。 |
| ReportKeyNameTest |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态或最终捆绑包中,则此密钥标识当前测试的名称。 |
| ReportKeyNumCurrent |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态或最终捆绑包中,则此键标识当前测试的序列号。 |
| ReportKeyNumTotal |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态或最终捆绑包中,则此密钥标识要运行的测试总数。 |
| ReportKeyStack |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态捆绑包中,则此密钥标识描述错误或失败的堆栈跟踪。 |
| ReportKeyStreamresult |
已过时.
如果包含在发送到 IInstrumentationWatcher 的状态或最终捆绑包中,则此键标识一个字符串,该字符串只需打印到输出流即可。 (继承自 Instrumentation) |
| ReportValueId |
已过时.
此值(如果使用键 |
属性
| 名称 | 说明 |
|---|---|
| AllocCounts |
已过时.
返回分配计数中当前结果的捆绑包。 (继承自 Instrumentation) |
| Arguments |
已过时.
获取传递给此检测的参数。 |
| BinderCounts |
已过时.
返回一个捆绑包,其中包含此过程的各种联编程序计数。 (继承自 Instrumentation) |
| Class |
已过时.
返回此 |
| ComponentName |
已过时.
返回此检测的完整组件名称。 (继承自 Instrumentation) |
| Context |
已过时.
返回此检测包的上下文。 (继承自 Instrumentation) |
| Handle |
已过时.
基础 Android 实例的句柄。 (继承自 Object) |
| IsProfiling |
已过时.
检查是否已启动此检测,并启用分析。 (继承自 Instrumentation) |
| JniIdentityHashCode |
已过时.
获取互操作运行时分配给此Java对等的标识哈希代码。 (继承自 Object) |
| JniManagedPeerState |
已过时.
获取运行时上次分配的状态标志。 (继承自 JavaObject) |
| JniPeerMembers |
已过时.
获取用于访问此Java绑定成员的 JNI 元数据。 |
| Loader |
已过时.
重写此选项以提供对包的类加载程序的访问权限。 |
| PeerReference |
已过时.
获取此Java对等方的 JNI 对象引用。 (继承自 Object) |
| ProcessName |
已过时.
返回运行此检测的进程的名称。 (继承自 Instrumentation) |
| TargetContext |
已过时.
返回要检测的目标应用程序的上下文。 (继承自 Instrumentation) |
| ThresholdClass |
已过时.
此 API 支持 Mono for Android 基础结构,不打算直接从代码使用。 |
| ThresholdType |
已过时.
此 API 支持 Mono for Android 基础结构,不打算直接从代码使用。 |
| UiAutomation |
已过时.
|
方法
显式接口实现
| 名称 | 说明 |
|---|---|
| IJavaPeerable.Disposed() |
已过时.
将此对等方标记为已释放,并将 |
| IJavaPeerable.Finalized() |
已过时.
将此对等方标记为已释放,并将 |
| IJavaPeerable.JniObjectReferenceControlBlock |
已过时.
获取此对等方使用的本机控制块指针。 (继承自 JavaObject) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
已过时.
存储运行时提供的标识哈希代码。 (继承自 JavaObject) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
已过时.
替换存储的托管对等状态标志。 (继承自 JavaObject) |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
已过时.
更新对等引用,并在引用无效时释放已释放的对等方控制块。 (继承自 JavaObject) |
扩展方法
| 名称 | 说明 |
|---|---|
| GetJniTypeName(IJavaPeerable) |
已过时.
获取实例 |
| JavaAs<TResult>(IJavaPeerable) |
已过时.
尝试强制 |
| JavaCast<TResult>(IJavaObject) |
已过时.
执行 Android 运行时检查的类型转换。 |
| JavaCast<TResult>(IJavaObject) |
已过时.
重复使用兼容的托管对等,或获取请求类型的包装器。 |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
已过时.
尝试强制 |