Android.Test.InstrumentationTestRunner Class
An Android.App.Instrumentation that runs various types of NoType:junit/framework/TestCase;Href=../../../reference/junit/framework/TestCase.htmls against an Android package (application).

See Also: InstrumentationTestRunner Members

Syntax

[Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)]
public class InstrumentationTestRunner : Android.App.Instrumentation

Remarks

An Android.App.Instrumentation that runs various types of NoType:junit/framework/TestCase;Href=../../../reference/junit/framework/TestCase.htmls against an Android package (application).

Developer Guides

For more information about application testing, read the Testing developer guide.

Typical Usage

  1. Write NoType:junit/framework/TestCase;Href=../../../reference/junit/framework/TestCase.htmls that perform unit, functional, or performance tests against the classes in your package. Typically these are subclassed from:
    • NoType:android/test/ActivityInstrumentationTestCase2;Href=../../../reference/android/test/ActivityInstrumentationTestCase2.html
    • NoType:android/test/ActivityUnitTestCase;Href=../../../reference/android/test/ActivityUnitTestCase.html
    • NoType:android/test/AndroidTestCase;Href=../../../reference/android/test/AndroidTestCase.html
    • NoType:android/test/ApplicationTestCase;Href=../../../reference/android/test/ApplicationTestCase.html
    • NoType:android/test/InstrumentationTestCase;Href=../../../reference/android/test/InstrumentationTestCase.html
    • NoType:android/test/ProviderTestCase;Href=../../../reference/android/test/ProviderTestCase.html
    • NoType:android/test/ServiceTestCase;Href=../../../reference/android/test/ServiceTestCase.html
    • NoType:android/test/SingleLaunchActivityTestCase;Href=../../../reference/android/test/SingleLaunchActivityTestCase.html
    • Set the android:targetPackage attribute of the <instrumentation> element in the test package's manifest. You should set the attribute value to the package name of the target application under test.
    • Run the instrumentation using "adb shell am instrument -w", with no optional arguments, to run all tests (except performance tests).
    • Run the instrumentation using "adb shell am instrument -w", with the argument '-e func true' to run all functional tests. These are tests that derive from NoType:android/test/InstrumentationTestCase;Href=../../../reference/android/test/InstrumentationTestCase.html.
    • Run the instrumentation using "adb shell am instrument -w", with the argument '-e unit true' to run all unit tests. These are tests that do notderive from NoType:android/test/InstrumentationTestCase;Href=../../../reference/android/test/InstrumentationTestCase.html (and are not performance tests).
    • Run the instrumentation using "adb shell am instrument -w", with the argument '-e class' set to run an individual NoType:junit/framework/TestCase;Href=../../../reference/junit/framework/TestCase.html.

    Running all tests: adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner

    Running all small tests: adb shell am instrument -w -e size small com.android.foo/android.test.InstrumentationTestRunner

    Running all medium tests: adb shell am instrument -w -e size medium com.android.foo/android.test.InstrumentationTestRunner

    Running all large tests: adb shell am instrument -w -e size large com.android.foo/android.test.InstrumentationTestRunner

    Filter test run to tests with given annotation: adb shell am instrument -w -e annotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

    If used with other options, the resulting test run will contain the union of the two options. e.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both the Android.Test.Suitebuilder.Annotation.ILargeTest and "com.android.foo.MyAnnotation" annotations.

    Filter test run to tests without given annotation: adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner

    Running a single testcase: adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/android.test.InstrumentationTestRunner

    Running a single test: adb shell am instrument -w -e class com.android.foo.FooTest#testFoo com.android.foo/android.test.InstrumentationTestRunner

    Running multiple tests: adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner

    Running all tests in a java package: adb shell am instrument -w -e package com.android.foo.subpkg com.android.foo/android.test.InstrumentationTestRunner

    Including performance tests: adb shell am instrument -w -e perf true com.android.foo/android.test.InstrumentationTestRunner

    To debug your tests, set a break point in your code and pass: -e debug true

    To run in 'log only' mode -e log true This option will load and iterate through all test classes and methods, but will bypass actual test execution. Useful for quickly obtaining info on the tests to be executed by an instrumentation command.

    To generate EMMA code coverage: -e coverage true Note: this requires an emma instrumented build. By default, the code coverage results file will be saved in a /data//coverage.ec file, unless overridden by coverageFile flag (see below)

    To specify EMMA code coverage results file path: -e coverageFile /sdcard/myFile.ec in addition to the other arguments.

    [Android Documentation]

    Requirements

    Namespace: Android.Test
    Assembly: Mono.Android (in Mono.Android.dll)
    Assembly Versions: 0.0.0.0
    Since: Added in API level 1