# AndroidJUnit4

Artifact: [androidx.test.ext:junit](https://developer.android.com/jetpack/androidx/releases/test-ext) [View Source](https://cs.android.com/search?q=file:androidx/test/ext/junit/runners/AndroidJUnit4.java+class:androidx.test.ext.junit.runners.AndroidJUnit4)

*** ** * ** ***


```
class AndroidJUnit4 : Runner, Filterable, Sortable
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [org.junit.runner.Runner](https://junit.org/junit4/javadoc/latest/org/junit/runner/Runner.html) ||
|   | ↳ | [androidx.test.ext.junit.runners.AndroidJUnit4](https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4) |

*** ** * ** ***

A JUnit4 runner for Android tests.

This runner offers several features on top of the standard JUnit4 runner,

- Supports running on Robolectric. This implementation will delegate to RobolectricTestRunner if test is running in Robolectric environment. A custom runner can be provided by specifying the full class name in a 'android.junit.runner' system property.
- Supports a per-test timeout - specified via a 'timeout_msec' `https://developer.android.com/reference/kotlin/androidx/test/runner/AndroidJUnitRunner` argument.
- Supports running tests on the application's UI Thread, for tests annotated with `https://developer.android.com/reference/kotlin/androidx/test/annotation/UiThreadTest`.

Usage `@RunWith(AndroidJUnit4.class)`

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4#AndroidJUnit4(java.lang.Class<?>)(klass: https://developer.android.com/reference/java/lang/Class.html<*>!)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4#filter(org.junit.runner.manipulation.Filter)(filter: https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/Filter.html!)` |
| `https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html!` | `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4#getDescription()()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4#run(org.junit.runner.notification.RunNotifier)(runNotifier: https://junit.org/junit4/javadoc/latest/org/junit/runner/notification/RunNotifier.html!)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/runners/AndroidJUnit4#sort(org.junit.runner.manipulation.Sorter)(sorter: https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/Sorter.html!)` |

### Inherited functions

From [org.junit.runner.Runner](https://junit.org/junit4/javadoc/latest/org/junit/runner/Runner.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://junit.org/junit4/javadoc/latest/org/junit/runner/Runner.html#testCount--()`

## Public constructors

### AndroidJUnit4

```
AndroidJUnit4(klass: Class<*>!)
```

## Public functions

### filter

```
fun filter(filter: Filter!): Unit
```

| Throws |
|---|---|
| `https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/NoTestsRemainException.html` |   |

### getDescription

```
fun getDescription(): Description!
```

### run

```
fun run(runNotifier: RunNotifier!): Unit
```

### sort

```
fun sort(sorter: Sorter!): Unit
```