# AndroidJUnitRunner

Artifact: [androidx.test:runner](https://developer.android.com/jetpack/androidx/releases/test) [View Source](https://cs.android.com/search?q=file:androidx/test/runner/AndroidJUnitRunner.java+class:androidx.test.runner.AndroidJUnitRunner)

*** ** * ** ***


```
class AndroidJUnitRunner : MonitoringInstrumentation
```

<br />

|---|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) ||||
| ↳ | [android.app.Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html) |||
|   | ↳ | [androidx.test.runner.MonitoringInstrumentation](https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation) ||
|   |   | ↳ | [androidx.test.runner.AndroidJUnitRunner](https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner) |

Known direct subclasses [AndroidBenchmarkRunner](https://developer.android.com/reference/kotlin/androidx/benchmark/junit4/AndroidBenchmarkRunner)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/benchmark/junit4/AndroidBenchmarkRunner` | Instrumentation runner for benchmarks, used to increase stability of measurements and minimize interference. |

*** ** * ** ***

An `https://developer.android.com/reference/android/app/Instrumentation.html` that runs JUnit3 and JUnit4 tests against an Android package (application).

Based on and replacement for `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html`. Supports a superset of `https://developer.android.com/reference/android/test/InstrumentationTestRunner.html` features, while maintaining command/output format compatibility with that class.

### Typical Usage

Write JUnit3 style s and/or JUnit4 style `https://junit.org/junit4/javadoc/latest/org/junit/Test.html`s that perform tests against the classes in your package. Make use of the `https://developer.android.com/reference/kotlin/androidx/test/InstrumentationRegistry` if needed.

In an appropriate AndroidManifest.xml, define an instrumentation with android:name set to `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner` and the appropriate android:targetPackage set.

#### Execution options:

**Running all tests:** adb shell am instrument -w com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Running all tests in a class:** adb shell am instrument -w -e class com.android.foo.FooTest com.android.foo/androidx.test.runner.AndroidJUnitRunner

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

**Running all tests in multiple classes:** adb shell am instrument -w -e class com.android.foo.FooTest,com.android.foo.TooTest com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Running all tests except those in a particular class:** adb shell am instrument -w -e notClass com.android.foo.FooTest com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Running all but a single test:** adb shell am instrument -w -e notClass com.android.foo.FooTest#testFoo com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Running all tests listed in a file:** adb shell am instrument -w -e testFile /sdcard/tmp/testFile.txt com.android.foo/com.android.test.runner.AndroidJUnitRunner The file should contain a list of line separated package names or test classes and optionally methods. Valid package names consist of one or more java identifiers delimited by the '.' character, in which the first character of the last identifier is not a capitalized letter. Valid class names consist of one or more java identifiers delimited by the '.' character, in which the first character of the last identifier is a capitalized letter. Valid method names are valid class names with a '#' character and an additional java identifier appended to the end. (expected class format: com.android.foo.FooClassName#testMethodName) (expected package format: com.android.foo) If -e useTestStorageService is also provided, the testfile will be converted to a relative path and retrieved from

**Running all tests not listed in a file:** adb shell am instrument -w -e notTestFile /sdcard/tmp/notTestFile.txt com.android.foo/com.android.test.runner.AndroidJUnitRunner The file should contain a list of line separated package names or test classes and optionally methods. Valid package names consist of one or more java identifiers delimited by the '.' character, in which the first character of the last identifier is not a capitalized letter. Valid class names consist of one or more java identifiers delimited by the '.' character, in which the first character of the last identifier is a capitalized letter. Valid method names are valid class names with a '#' character and an additional java identifier appended to the end. (expected class format: com.android.foo.FooClassName#testMethodName) (expected package format: com.android.foo) If -e useTestStorageService is also provided, the testfile will be converted to a relative path and retrieved from

**Running all tests in a java package:** adb shell am instrument -w -e package com.android.foo.bar com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Running all tests except a particular package:** adb shell am instrument -w -e notPackage com.android.foo.bar com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Running all tests matching a given regular expression:** adb shell am instrument -w -e tests_regex BarTest.\* com.android.foo/androidx.test.runner.AndroidJUnitRunner

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

**Running a specific test size i.e. annotated with `https://developer.android.com/reference/kotlin/androidx/test/filters/SmallTest` or `https://developer.android.com/reference/kotlin/androidx/test/filters/MediumTest` or `https://developer.android.com/reference/kotlin/androidx/test/filters/LargeTest`:** adb shell am instrument -w -e size \[small\|medium\|large\] com.android.foo/androidx.test.runner.AndroidJUnitRunner

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

If used with other options, the resulting test run will contain the intersection of the two options. e.g. "-e size large -e annotation com.android.foo.MyAnnotation" will run only tests with both the `https://developer.android.com/reference/kotlin/androidx/test/filters/LargeTest` and "com.android.foo.MyAnnotation" annotations.

**Filter test run to tests *with all* annotations in a list:** adb shell am instrument -w -e annotation com.android.foo.MyAnnotation,com.android.foo.AnotherAnnotation com.android.foo/androidx.test.runner.AndroidJUnitRunner

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

As above, if used with other options, the resulting test run will contain the intersection of the two options. e.g. "-e size large -e notAnnotation com.android.foo.MyAnnotation" will run tests with the `https://developer.android.com/reference/kotlin/androidx/test/filters/LargeTest` annotation that do NOT have the "com.android.foo.MyAnnotation" annotations.

**Filter test run to tests *without any* of a list of annotations:** adb shell am instrument -w -e notAnnotation com.android.foo.MyAnnotation,com.android.foo.AnotherAnnotation com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Filter test run to tests that pass all of a list of custom `https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/Filter.html`:** adb shell am instrument -w -e filter com.android.foo.MyCustomFilter,com.android.foo.AnotherCustomFilter com.android.foo/androidx.test.runner.AndroidJUnitRunner

A `https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/Filter.html` class provided to the `filter` option must be public and must provide a public constructor of one of the following patterns. They are searched in order and the first one found is the one that is used.

1. `<init>()` - a no arguments constructor. This is for filters whose behavior is hard coded.
2. `<init>(Bundle bundle` - accepts a `https://developer.android.com/reference/android/os/Bundle.html` that contains the options passed to this instance. This is for filters whose behavior needs to be configured through additional options to `am instrument`.

**Filter test run to a shard of all tests, where numShards is an integer greater than 0 and shardIndex is an integer between 0 (inclusive) and numShards (exclusive):** adb shell am instrument -w -e numShards 4 -e shardIndex 1 com.android.foo/androidx.test.runner.AndroidJUnitRunner

**Use custom `https://junit.org/junit4/javadoc/latest/org/junit/runners/model/RunnerBuilder.html` to run test classes:** adb shell am instrument -w -e runnerBuilder com.android.foo.MyCustomBuilder,com.android.foo.AnotherCustomBuilder com.android.foo/androidx.test.runner.AndroidJUnitRunner

A `https://junit.org/junit4/javadoc/latest/org/junit/runners/model/RunnerBuilder.html` class provided to the `runnerBuilder` option must be public and must provide a public no-argument constructor.

**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 code coverage files (\*.ec) that can be used by EMMA or JaCoCo:** -e coverage true Note: For this to work, your classes have to be instrumented offline (i.e. at build time) by EMMA/JaCoCo. By default, the code coverage results file will be saved in a /data/data//files/coverage.ec file, unless overridden by coverageFile flag (see below)

**To specify EMMA or JaCoCo code coverage results file path:** -e coverage true -e coverageFile /sdcard/myFile.ec

**To specify one or more `https://junit.org/junit4/javadoc/latest/org/junit/runner/notification/RunListener.html`s to observe the test run:** -e listener com.foo.Listener,com.foo.Listener2

**To use the new order of `https://junit.org/junit4/javadoc/latest/org/junit/runner/notification/RunListener.html`s during a test run:** -e newRunListenerMode true

New order of listeners guarantee that user defined `https://junit.org/junit4/javadoc/latest/org/junit/runner/notification/RunListener.html`s will be running before any of the default listeners defined in this runner. Legacy order had those user defined listeners running after the default ones.

Note:The new order will become the default in the future.

`https://junit.org/junit4/javadoc/latest/org/junit/runner/notification/RunListener.html` can also be specified via `https://developer.android.com/reference/java/util/ServiceLoader.html` metadata.

**To specify a custom `https://developer.android.com/reference/java/lang/ClassLoader.html` to load the test class:** -e classLoader com.foo.CustomClassLoader

**Deprecated: Set timeout (in milliseconds) that will be applied to each test:** -e timeout_msec 5000 -e timeout essentially reuses the deprecated @Test(timeout) functionality. Use junit's Timeout Rule instead.

Supported for both JUnit3 and JUnit4 style tests. For JUnit3 tests, this flag is the only way to specify timeouts. For JUnit4 tests, this flag is only supported when using the the `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4` runner. It overrides timeouts specified via `https://junit.org/junit4/javadoc/latest/org/junit/rules/Timeout.html`. Please note that in JUnit4 `https://junit.org/junit4/javadoc/latest/org/junit/Test.html#timeout--` annotation will take precedence over both, this flag and `https://junit.org/junit4/javadoc/latest/org/junit/rules/Timeout.html` rule.

**(Beta)To specify a custom `https://developer.android.com/reference/kotlin/androidx/test/runner/screenshot/ScreenCaptureProcessor` to use when processing a `https://developer.android.com/reference/kotlin/androidx/test/runner/screenshot/ScreenCapture` produced by `https://developer.android.com/reference/kotlin/androidx/test/runner/screenshot/Screenshot#capture()`**: -e screenCaptureProcessors com.foo.Processor,com.foo.Processor2

If no `https://developer.android.com/reference/kotlin/androidx/test/runner/screenshot/ScreenCaptureProcessor` is provided then the `https://developer.android.com/reference/kotlin/androidx/test/runner/screenshot/BasicScreenCaptureProcessor` is used. If one or more are provided the `https://developer.android.com/reference/kotlin/androidx/test/runner/screenshot/BasicScreenCaptureProcessor` is not used unless it is one of the ones provided.

**(Beta) To specify a remote static method for the runner to attempt to call reflectively:** adb shell am instrument -w -e remoteMethod com.foo.bar#init

**Note:** The method must be static. Usually used to initiate a remote testing client that depends on the runner (e.g. Espresso).

**All arguments can also be specified in the in the AndroidManifest via a meta-data tag:**

eg. using listeners:

```kotlin
<instrumentation
   android:name="androidx.test.runner.AndroidJUnitRunner"
   android:targetPackage="com.foo.Bar">
   <meta-data
       android:name="listener"
       android:value="com.foo.Listener,com.foo.Listener2" />
</instrumentation>
```
Arguments specified via shell will override manifest specified arguments.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner#AndroidJUnitRunner()()` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner#onCreate(android.os.Bundle)(arguments: https://developer.android.com/reference/android/os/Bundle.html!)` Sets up lifecycle monitoring, and argument registry. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner#onException(java.lang.Object,java.lang.Throwable)(obj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, e: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner#onStart()()` This implementation of onStart() will guarantee that the Application's onCreate method has completed when it returns. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner#sendStatus(int,android.os.Bundle)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, results: https://developer.android.com/reference/android/os/Bundle.html!)` |

### Inherited Constants

From [android.app.Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#REPORT_KEY_IDENTIFIER = "id"` `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#REPORT_KEY_STREAMRESULT = "stream"`

### Inherited functions

From [android.app.Instrumentation](https://developer.android.com/reference/android/app/Instrumentation.html) `https://developer.android.com/reference/android/os/TestLooperManager.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#acquireLooperManager(android.os.Looper)(looper: https://developer.android.com/reference/android/os/Looper.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#addMonitor(android.app.Instrumentation.ActivityMonitor)(monitor: https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html!)` `https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#addMonitor(android.content.IntentFilter, android.app.Instrumentation.ActivityResult, boolean)(
filter: https://developer.android.com/reference/android/content/IntentFilter.html!,
result: https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html!,
block: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#addResults(android.os.Bundle)(results: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnCreate(android.app.Activity, android.os.Bundle)(activity: https://developer.android.com/reference/android/app/Activity.html!, icicle: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnDestroy(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnNewIntent(android.app.Activity, android.content.Intent)(activity: https://developer.android.com/reference/android/app/Activity.html!, intent: https://developer.android.com/reference/android/content/Intent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnPause(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnPictureInPictureRequested(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnPostCreate(android.app.Activity, android.os.Bundle)(activity: https://developer.android.com/reference/android/app/Activity.html!, savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnRestart(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnRestoreInstanceState(android.app.Activity, android.os.Bundle)(
activity: https://developer.android.com/reference/android/app/Activity.html!,
savedInstanceState: https://developer.android.com/reference/android/os/Bundle.html!
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnResume(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnSaveInstanceState(android.app.Activity, android.os.Bundle)(activity: https://developer.android.com/reference/android/app/Activity.html!, outState: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnStart(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnStop(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callActivityOnUserLeaving(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#callApplicationOnCreate(android.app.Application)(app: https://developer.android.com/reference/android/app/Application.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#checkMonitorHit(android.app.Instrumentation.ActivityMonitor, int)(monitor: https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html!, minHits: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#endPerformanceSnapshot()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#finish(int, android.os.Bundle)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, results: https://developer.android.com/reference/android/os/Bundle.html!)` `https://developer.android.com/reference/android/os/Bundle.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getAllocCounts()()` `https://developer.android.com/reference/android/os/Bundle.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getBinderCounts()()` `https://developer.android.com/reference/android/content/ComponentName.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getComponentName()()` `https://developer.android.com/reference/android/content/Context.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getContext()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getProcessName()()` `https://developer.android.com/reference/android/content/Context.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getTargetContext()()` `https://developer.android.com/reference/android/app/UiAutomation.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#getUiAutomation()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#invokeContextMenuAction(android.app.Activity, int, int)(targetActivity: https://developer.android.com/reference/android/app/Activity.html!, id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#invokeMenuActionSync(android.app.Activity, int, int)(targetActivity: https://developer.android.com/reference/android/app/Activity.html!, id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, flag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#isProfiling()()` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#newActivity(java.lang.Class&lt;?&gt;, android.content.Context, android.os.IBinder, android.app.Application, android.content.Intent, android.content.pm.ActivityInfo, java.lang.CharSequence, android.app.Activity, java.lang.String, java.lang.Object)(
clazz: https://developer.android.com/reference/java/lang/Class.html<*>!,
context: https://developer.android.com/reference/android/content/Context.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
application: https://developer.android.com/reference/android/app/Application.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
info: https://developer.android.com/reference/android/content/pm/ActivityInfo.html!,
title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!,
parent: https://developer.android.com/reference/android/app/Activity.html!,
id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
lastNonConfigurationInstance: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!
)` `java-static https://developer.android.com/reference/android/app/Application.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#newApplication(java.lang.Class&lt;?&gt;, android.content.Context)(clazz: https://developer.android.com/reference/java/lang/Class.html<*>!, context: https://developer.android.com/reference/android/content/Context.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#onCreate(android.os.Bundle)(arguments: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#onDestroy()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#onException(java.lang.Object, java.lang.Throwable)(obj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!, e: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#onStart()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#removeMonitor(android.app.Instrumentation.ActivityMonitor)(monitor: https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#resetInTouchMode()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#runOnMainSync(java.lang.Runnable)(runner: https://developer.android.com/reference/java/lang/Runnable.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#sendCharacterSync(int)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#sendKeyDownUpSync(int)(keyCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#sendKeySync(android.view.KeyEvent)(event: https://developer.android.com/reference/android/view/KeyEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#sendPointerSync(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#sendStringSync(java.lang.String)(text: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#sendTrackballEventSync(android.view.MotionEvent)(event: https://developer.android.com/reference/android/view/MotionEvent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#setAutomaticPerformanceSnapshots()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#setInTouchMode(boolean)(inTouch: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#start()()` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#startActivitySync(android.content.Intent)(intent: https://developer.android.com/reference/android/content/Intent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#startAllocCounting()()`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#startPerformanceSnapshot()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#startProfiling()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#stopAllocCounting()()`

**This function is deprecated.**
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#stopProfiling()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#waitForIdle(java.lang.Runnable)(recipient: https://developer.android.com/reference/java/lang/Runnable.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/android/app/Instrumentation.html#waitForIdleSync()()` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#waitForMonitor(android.app.Instrumentation.ActivityMonitor)(monitor: https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html!)` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/android/app/Instrumentation.html#waitForMonitorWithTimeout(android.app.Instrumentation.ActivityMonitor, long)(
monitor: https://developer.android.com/reference/android/app/Instrumentation.ActivityMonitor.html!,
timeOut: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html
)` From [androidx.test.runner.MonitoringInstrumentation](https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnCreate(android.app.Activity,android.os.Bundle)(activity: https://developer.android.com/reference/android/app/Activity.html!, bundle: https://developer.android.com/reference/android/os/Bundle.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnCreate(android.app.Activity,android.os.Bundle,android.os.PersistableBundle)(
activity: https://developer.android.com/reference/android/app/Activity.html!,
bundle: https://developer.android.com/reference/android/os/Bundle.html!,
persistentState: https://developer.android.com/reference/android/os/PersistableBundle.html!
)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnDestroy(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnPause(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnRestart(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnResume(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnStart(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callActivityOnStop(android.app.Activity)(activity: https://developer.android.com/reference/android/app/Activity.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#callApplicationOnCreate(android.app.Application)(app: https://developer.android.com/reference/android/app/Application.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#dumpThreadStateToOutputs(java.lang.String)(outputFileName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#execStartActivities(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Activity,android.content.Intent[],android.os.Bundle)(
who: https://developer.android.com/reference/android/content/Context.html!,
contextThread: https://developer.android.com/reference/android/os/IBinder.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
target: https://developer.android.com/reference/android/app/Activity.html!,
intents: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://developer.android.com/reference/android/content/Intent.html!>!,
options: https://developer.android.com/reference/android/os/Bundle.html!
)` `https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Activity,android.content.Intent,int)(
who: https://developer.android.com/reference/android/content/Context.html!,
contextThread: https://developer.android.com/reference/android/os/IBinder.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
target: https://developer.android.com/reference/android/app/Activity.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
requestCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html
)` `https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Activity,android.content.Intent,int,android.os.Bundle)(
who: https://developer.android.com/reference/android/content/Context.html!,
contextThread: https://developer.android.com/reference/android/os/IBinder.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
target: https://developer.android.com/reference/android/app/Activity.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
requestCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
options: https://developer.android.com/reference/android/os/Bundle.html!
)` `https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Fragment,android.content.Intent,int,android.os.Bundle)(
who: https://developer.android.com/reference/android/content/Context.html!,
contextThread: https://developer.android.com/reference/android/os/IBinder.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
target: https://developer.android.com/reference/android/app/Fragment.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
requestCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
options: https://developer.android.com/reference/android/os/Bundle.html!
)` `https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,java.lang.String,android.content.Intent,int,android.os.Bundle)(
who: https://developer.android.com/reference/android/content/Context.html!,
contextThread: https://developer.android.com/reference/android/os/IBinder.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
target: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
requestCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
options: https://developer.android.com/reference/android/os/Bundle.html!
)`

This API was added in Android API 23 (M)
`https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#execStartActivity(android.content.Context,android.os.IBinder,android.os.IBinder,android.app.Activity,android.content.Intent,int,android.os.Bundle,android.os.UserHandle)(
who: https://developer.android.com/reference/android/content/Context.html!,
contextThread: https://developer.android.com/reference/android/os/IBinder.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
target: https://developer.android.com/reference/android/app/Activity.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
requestCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html,
options: https://developer.android.com/reference/android/os/Bundle.html!,
user: https://developer.android.com/reference/android/os/UserHandle.html!
)`

This API was added in Android API 17 (JELLY_BEAN_MR1)
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#finish(int,android.os.Bundle)(resultCode: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, results: https://developer.android.com/reference/android/os/Bundle.html!)`

Ensures all activities launched in this instrumentation are finished before the instrumentation exits.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#getThreadState()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[installMultidex](https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#installMultidex())()`

**This function is deprecated.**

no-op: multidex is not necessary on SDKS \>= 23

<br />

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `[installOldMultiDex](https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#installOldMultiDex(java.lang.Class<?>))(multidexClass: https://developer.android.com/reference/java/lang/Class.html<*>!)`

**This function is deprecated.**

no-op: multidex is not necessary on SDKS \>= 23

<br />

`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#interceptActivityUsing(androidx.test.runner.intercepting.InterceptingActivityFactory)(
interceptingActivityFactory: https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/InterceptingActivityFactory!
)`

Use the given InterceptingActivityFactory to create Activity instance in `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#newActivity(java.lang.ClassLoader,java.lang.String,android.content.Intent)`.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#isPrimaryInstrProcess()()`

Checks whether this instance of instrumentation should be considered as a primary instrumentation process.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `[isPrimaryInstrProcess](https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#isPrimaryInstrProcess(java.lang.String))(argsProcessName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?)`

**This function is deprecated.**

use isPrimaryInstrProcess()

<br />

`https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#newActivity(java.lang.ClassLoader,java.lang.String,android.content.Intent)(cl: https://developer.android.com/reference/java/lang/ClassLoader.html!, className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, intent: https://developer.android.com/reference/android/content/Intent.html!)` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#newActivity(java.lang.Class<?>,android.content.Context,android.os.IBinder,android.app.Application,android.content.Intent,android.content.pm.ActivityInfo,java.lang.CharSequence,android.app.Activity,java.lang.String,java.lang.Object)(
clazz: https://developer.android.com/reference/java/lang/Class.html<*>!,
context: https://developer.android.com/reference/android/content/Context.html!,
token: https://developer.android.com/reference/android/os/IBinder.html!,
application: https://developer.android.com/reference/android/app/Application.html!,
intent: https://developer.android.com/reference/android/content/Intent.html!,
info: https://developer.android.com/reference/android/content/pm/ActivityInfo.html!,
title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!,
parent: https://developer.android.com/reference/android/app/Activity.html!,
id: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!,
lastNonConfigurationInstance: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!
)` `https://developer.android.com/reference/android/app/Application.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#newApplication(java.lang.ClassLoader,java.lang.String,android.content.Context)(cl: https://developer.android.com/reference/java/lang/ClassLoader.html!, className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, context: https://developer.android.com/reference/android/content/Context.html!)`

Does initialization before creating the application.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#onDestroy()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#restoreUncaughtExceptionHandler()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#runOnMainSync(java.lang.Runnable)(runnable: https://developer.android.com/reference/java/lang/Runnable.html!)`

Posts a runnable to the main thread and blocks the caller's thread until the runnable is executed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#setJsBridgeClassName(java.lang.String)(className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#shouldWaitForActivitiesToComplete()()` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#specifyDexMakerCacheProperty()()` `https://developer.android.com/reference/android/app/Activity.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#startActivitySync(android.content.Intent)(intent: https://developer.android.com/reference/android/content/Intent.html!)` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#unwrapException(java.lang.Throwable)(t: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-throwable/index.html!)`

Unwraps an exception from certain wrapper types, e.g. RuntimeException.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#useDefaultInterceptingActivityFactory()()`

Use default mechanism of creating activity instance in `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#newActivity(java.lang.ClassLoader,java.lang.String,android.content.Intent)`
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/test/runner/MonitoringInstrumentation#waitForActivitiesToComplete()()`

Ensures we've onStopped() all activities which were onStarted().

## Public constructors

### AndroidJUnitRunner

```
AndroidJUnitRunner()
```

## Public functions

### onCreate

```
fun onCreate(arguments: Bundle!): Unit
```

Sets up lifecycle monitoring, and argument registry.

Subclasses must call up to onCreate(). This onCreate method does not call start() it is the subclasses responsibility to call start if it desires.

### onException

```
fun onException(obj: Any!, e: Throwable!): Boolean
```

### onStart

```
fun onStart(): Unit
```

This implementation of onStart() will guarantee that the Application's onCreate method has completed when it returns.

Subclasses should call super.onStart() before executing any code that touches the application and it's state.

### sendStatus

```
fun sendStatus(resultCode: Int, results: Bundle!): Unit
```