# AndroidJUnit4

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

*** ** * ** ***


```
public final class AndroidJUnit4 extends Runner implements Filterable, Sortable
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [org.junit.runner.Runner](https://junit.org/junit4/javadoc/latest/org/junit/runner/Runner.html) ||
|   | ↳ | [androidx.test.runner.AndroidJUnit4](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4) |

*** ** * ** ***

> [!CAUTION]
> **This class is deprecated.**   
>
> use `https://developer.android.com/reference/androidx/test/ext/junit/runners/AndroidJUnit4` instead.

Aliases the current default Android JUnit 4 class runner, for future-proofing. If future versions of JUnit change the default Runner class, they will also change the definition of this class. Developers wanting to explicitly tag a class as an Android JUnit 4 class should use `@RunWith(AndroidJUnit4.class)`

## Summary

| ### Public constructors |
|---|
| `[AndroidJUnit4](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#AndroidJUnit4(java.lang.Class<?>))(https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?> klass)` **This method is deprecated.** Deprecated in Java |

| ### Public methods |
|---|---|
| `void` | `[filter](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#filter(org.junit.runner.manipulation.Filter))(https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/Filter.html filter)` **This method is deprecated.** Deprecated in Java |
| `https://junit.org/junit4/javadoc/latest/org/junit/runner/Description.html` | `[getDescription](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#getDescription())()` **This method is deprecated.** Deprecated in Java |
| `void` | `[run](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#run(org.junit.runner.notification.RunNotifier))(https://junit.org/junit4/javadoc/latest/org/junit/runner/notification/RunNotifier.html runNotifier)` **This method is deprecated.** Deprecated in Java |
| `void` | `[sort](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#sort(org.junit.runner.manipulation.Sorter))(https://junit.org/junit4/javadoc/latest/org/junit/runner/manipulation/Sorter.html sorter)` **This method is deprecated.** Deprecated in Java |

### Inherited methods

From [org.junit.runner.Runner](https://junit.org/junit4/javadoc/latest/org/junit/runner/Runner.html) `int` `[testCount](https://junit.org/junit4/javadoc/latest/org/junit/runner/Runner.html#testCount--)()`

**This method is deprecated.** Deprecated in Java

## Public constructors

### AndroidJUnit4

```
public [AndroidJUnit4](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#AndroidJUnit4(java.lang.Class<?>))(Class<@NonNull ?> klass)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

Used when executed with standard junit runner. Will attempt to delegate to RobolectricTestRunner or delegate provided by android.junit.runner system property.

## Public methods

### filter

```
public void [filter](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#filter(org.junit.runner.manipulation.Filter))(Filter filter)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

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

### getDescription

```
public Description [getDescription](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#getDescription())()
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

### run

```
public void [run](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#run(org.junit.runner.notification.RunNotifier))(RunNotifier runNotifier)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java

### sort

```
public void [sort](https://developer.android.com/reference/androidx/test/runner/AndroidJUnit4#sort(org.junit.runner.manipulation.Sorter))(Sorter sorter)
```

> [!CAUTION]
> **This method is deprecated.**   
> Deprecated in Java