InstrumentationTestRunner Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
An Instrumentation
that runs various types of junit.framework.TestCase
s against
an Android package (application).
[Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)]
public class InstrumentationTestRunner : Android.App.Instrumentation
[<Android.Runtime.Register("android/test/InstrumentationTestRunner", DoNotGenerateAcw=true)>]
type InstrumentationTestRunner = class
inherit Instrumentation
- Inheritance
- Attributes
Remarks
An Instrumentation
that runs various types of junit.framework.TestCase
s against an Android package (application).
<div class="special reference"> <h3>Developer Guides</h3>
For more information about application testing, read the Testing developer guide.
</div>
<h3>Typical Usage</h3> <ol> <li>Write junit.framework.TestCase
s that perform unit, functional, or performance tests against the classes in your package. Typically these are subclassed from: <ul><li>android.test.ActivityInstrumentationTestCase2
</li> <li>android.test.ActivityUnitTestCase
</li> <li>android.test.AndroidTestCase
</li> <li>android.test.ApplicationTestCase
</li> <li>android.test.InstrumentationTestCase
</li> <li>android.test.ProviderTestCase
</li> <li>android.test.ServiceTestCase
</li> <li>android.test.SingleLaunchActivityTestCase
</li></ul> <li>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. <li>Run the instrumentation using "adb shell am instrument -w", with no optional arguments, to run all tests (except performance tests). <li>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 android.test.InstrumentationTestCase
. <li>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 android.test.InstrumentationTestCase
(and are not performance tests). <li>Run the instrumentation using "adb shell am instrument -w", with the argument '-e class' set to run an individual junit.framework.TestCase
. </ol> <p/> <b>Running all tests:</b> adb shell am instrument -w com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running all small tests:</b> adb shell am instrument -w -e size small com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running all medium tests:</b> adb shell am instrument -w -e size medium com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running all large tests:</b> adb shell am instrument -w -e size large com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Filter test run to tests with given annotation:</b> adb shell am instrument -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.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both the LargeTest
and "com.android.foo.MyAnnotation" annotations. <p/> <b>Filter test run to tests without given annotation:</b> adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running a single testcase:</b> adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running a single test:</b> adb shell am instrument -w -e class com.android.foo.FooTest#testFoo com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running multiple tests:</b> adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Running all tests in a java package:</b> adb shell am instrument -w -e package com.android.foo.subpkg com.android.foo/android.test.InstrumentationTestRunner <p/> <b>Including performance tests:</b> adb shell am instrument -w -e perf true com.android.foo/android.test.InstrumentationTestRunner <p/> <b>To debug your tests, set a break point in your code and pass:</b> -e debug true <p/> <b>To run in 'log only' mode</b> -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. <p/> <b>To generate EMMA code coverage:</b> -e coverage true Note: this requires an emma instrumented build. By default, the code coverage results file will be saved in a /data/<app>/coverage.ec file, unless overridden by coverageFile flag (see below) <p/> <b> To specify EMMA code coverage results file path:</b> -e coverageFile /sdcard/myFile.ec <br/> in addition to the other arguments.
This member is deprecated. Use AndroidJUnitRunner instead. New tests should be written using the Android Testing Support Library.
Java documentation for android.test.InstrumentationTestRunner
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
InstrumentationTestRunner() | |
InstrumentationTestRunner(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Fields
ReportKeyIdentifier |
If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the class that is writing the report. (Inherited from Instrumentation) |
ReportKeyNameClass |
If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the name of the current test class. |
ReportKeyNameTest |
If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the name of the current test. |
ReportKeyNumCurrent |
If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the sequence number of the current test. |
ReportKeyNumTotal |
If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies the total number of tests that are being run. |
ReportKeyStack |
If included in the status bundle sent to an IInstrumentationWatcher, this key identifies a stack trace describing an error or failure. |
ReportKeyStreamresult |
If included in the status or final bundle sent to an IInstrumentationWatcher, this key identifies a string which can simply be printed to the output stream. (Inherited from Instrumentation) |
ReportValueId |
This value, if stored with key |
Properties
AllocCounts |
Returns a bundle with the current results from the allocation counting. (Inherited from Instrumentation) |
Arguments |
Get the arguments passed to this instrumentation. |
BinderCounts |
Returns a bundle with the counts for various binder counts for this process. (Inherited from Instrumentation) |
Class |
Returns the runtime class of this |
ComponentName |
Returns complete component name of this instrumentation. (Inherited from Instrumentation) |
Context |
Return the Context of this instrumentation's package. (Inherited from Instrumentation) |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
IsProfiling |
Check whether this instrumentation was started with profiling enabled. (Inherited from Instrumentation) |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
Loader |
Override this to provide access to the class loader of your package. |
PeerReference | (Inherited from Object) |
ProcessName |
Return the name of the process this instrumentation is running in. (Inherited from Instrumentation) |
TargetContext |
Return a Context for the target application being instrumented. (Inherited from Instrumentation) |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
UiAutomation |
Gets the |
Methods
AcquireLooperManager(Looper) |
Takes control of the execution of messages on the specified looper until
|
AddMonitor(Instrumentation+ActivityMonitor) |
Add a new |
AddMonitor(IntentFilter, Instrumentation+ActivityResult, Boolean) |
Add a new |
AddMonitor(String, Instrumentation+ActivityResult, Boolean) |
Add a new |
AddResults(Bundle) |
Report some results in the middle of instrumentation execution. (Inherited from Instrumentation) |
CallActivityOnCreate(Activity, Bundle, PersistableBundle) |
Perform calling of an activity's |
CallActivityOnCreate(Activity, Bundle) |
Perform calling of an activity's |
CallActivityOnDestroy(Activity) | (Inherited from Instrumentation) |
CallActivityOnNewIntent(Activity, Intent) |
Perform calling of an activity's |
CallActivityOnPause(Activity) |
Perform calling of an activity's |
CallActivityOnPictureInPictureRequested(Activity) |
Perform calling of an activity's |
CallActivityOnPostCreate(Activity, Bundle, PersistableBundle) |
Perform calling of an activity's |
CallActivityOnPostCreate(Activity, Bundle) |
Perform calling of an activity's |
CallActivityOnRestart(Activity) |
Perform calling of an activity's |
CallActivityOnRestoreInstanceState(Activity, Bundle, PersistableBundle) |
Perform calling of an activity's |
CallActivityOnRestoreInstanceState(Activity, Bundle) |
Perform calling of an activity's |
CallActivityOnResume(Activity) |
Perform calling of an activity's |
CallActivityOnSaveInstanceState(Activity, Bundle, PersistableBundle) |
Perform calling of an activity's |
CallActivityOnSaveInstanceState(Activity, Bundle) |
Perform calling of an activity's |
CallActivityOnStart(Activity) |
Perform calling of an activity's |
CallActivityOnStop(Activity) |
Perform calling of an activity's |
CallActivityOnUserLeaving(Activity) |
Perform calling of an activity's |
CallApplicationOnCreate(Application) |
Perform calling of the application's |
CheckMonitorHit(Instrumentation+ActivityMonitor, Int32) |
Test whether an existing |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
EndPerformanceSnapshot() | (Inherited from Instrumentation) |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
Finish(Result, Bundle) |
Terminate instrumentation of the application. (Inherited from Instrumentation) |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetUiAutomation(UiAutomationFlags) |
Gets the |
InvokeContextMenuAction(Activity, Int32, MenuPerformFlags) |
Show the context menu for the currently focused view and executes a particular context menu item. (Inherited from Instrumentation) |
InvokeMenuActionSync(Activity, Int32, MenuPerformFlags) |
Execute a particular menu item. (Inherited from Instrumentation) |
JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
NewActivity(Class, Context, IBinder, Application, Intent, ActivityInfo, ICharSequence, Activity, String, Object) |
Perform instantiation of an |
NewActivity(Class, Context, IBinder, Application, Intent, ActivityInfo, String, Activity, String, Object) |
Perform instantiation of an |
NewActivity(ClassLoader, String, Intent) |
Perform instantiation of the process's |
NewApplication(ClassLoader, String, Context) |
Perform instantiation of the process's |
Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
OnCreate(Bundle) |
Called when the instrumentation is starting, before any application code has been loaded. (Inherited from Instrumentation) |
OnDestroy() |
Called when the instrumented application is stopping, after all of the normal application cleanup has occurred. (Inherited from Instrumentation) |
OnException(Object, Throwable) |
This is called whenever the system captures an unhandled exception that was thrown by the application. (Inherited from Instrumentation) |
OnStart() |
Method where the instrumentation thread enters execution. (Inherited from Instrumentation) |
RemoveMonitor(Instrumentation+ActivityMonitor) |
Remove an |
ResetInTouchMode() |
Resets the |
RunOnMainSync(Action) | (Inherited from Instrumentation) |
RunOnMainSync(IRunnable) |
Execute a call on the application's main thread, blocking until it is complete. (Inherited from Instrumentation) |
SendCharacterSync(Keycode) |
Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed. (Inherited from Instrumentation) |
SendKeyDownUpSync(Keycode) |
Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed. (Inherited from Instrumentation) |
SendKeySync(KeyEvent) |
Sends a key event to the currently focused window, and waits for it to be processed. (Inherited from Instrumentation) |
SendPointerSync(MotionEvent) |
Dispatches a pointer event into a window owned by the instrumented application, and waits for it to be processed. (Inherited from Instrumentation) |
SendStatus(Result, Bundle) |
Provide a status report about the application. (Inherited from Instrumentation) |
SendStringSync(String) |
Sends the key events that result in the given text being typed into the currently focused window, and waits for it to be processed. (Inherited from Instrumentation) |
SendTrackballEventSync(MotionEvent) |
Dispatches a trackball event into the currently focused window, and waits for it to be processed. (Inherited from Instrumentation) |
SetAutomaticPerformanceSnapshots() | (Inherited from Instrumentation) |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetInTouchMode(Boolean) |
Force the global system in or out of touch mode. (Inherited from Instrumentation) |
Start() |
Create and start a new thread in which to run instrumentation. (Inherited from Instrumentation) |
StartActivitySync(Intent, Bundle) |
Start a new activity and wait for it to begin running before returning. (Inherited from Instrumentation) |
StartActivitySync(Intent) |
Start a new activity and wait for it to begin running before returning. (Inherited from Instrumentation) |
StartAllocCounting() | (Inherited from Instrumentation) |
StartPerformanceSnapshot() | (Inherited from Instrumentation) |
StartProfiling() |
This method will start profiling if isProfiling() returns true. (Inherited from Instrumentation) |
StopAllocCounting() | (Inherited from Instrumentation) |
StopProfiling() |
Stops profiling if isProfiling() returns true. (Inherited from Instrumentation) |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnregisterFromRuntime() | (Inherited from Object) |
Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
WaitForIdle(Action) | (Inherited from Instrumentation) |
WaitForIdle(IRunnable) |
Schedule a callback for when the application's main thread goes idle (has no more events to process). (Inherited from Instrumentation) |
WaitForIdleSync() |
Synchronously wait for the application to be idle. (Inherited from Instrumentation) |
WaitForMonitor(Instrumentation+ActivityMonitor) |
Wait for an existing |
WaitForMonitorWithTimeout(Instrumentation+ActivityMonitor, Int64) |
Wait for an existing |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |