# AndroidJUnit4

Summary:[Ctors](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#pubctors)\|[Methods](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#)  

# AndroidJUnit4

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
AndroidJUnit4
`  
`


``

extends Runner


``


implements

Filterable,

Sortable


`

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

<br />

*** ** * ** ***

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/android/support/test/runner/AndroidJUnit4#AndroidJUnit4(java.lang.Class<?>, android.support.test.internal.util.AndroidRunnerParams))`(`[Class](https://developer.android.com/reference/java/lang/Class.html)`<?> klass, AndroidRunnerParams runnerParams) ` Constructs a new instance of the default runner |
| ` `[AndroidJUnit4](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#AndroidJUnit4(java.lang.Class<?>))`(`[Class](https://developer.android.com/reference/java/lang/Class.html)`<?> klass) ` Used when executed with standard junit runner.                                                                                            |

|                                                                                   ### Public methods                                                                                   ||
|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`        | ` `[filter](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#filter(org.junit.runner.manipulation.Filter))`(Filter filter) `          |
| ` Description` | ` `[getDescription](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#getDescription())`() `                                           |
| ` void`        | ` `[run](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#run(org.junit.runner.notification.RunNotifier))`(RunNotifier runNotifier) ` |
| ` void`        | ` `[sort](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#sort(org.junit.runner.manipulation.Sorter))`(Sorter sorter) `              |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#)From class` org.junit.runner.Runner ` |-------------------------|---------------------------| | ` abstract Description` | ` getDescription() `      | | ` abstract void`        | ` run(RunNotifier arg0) ` | | ` int`                  | ` testCount() `           | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#)From interface` org.junit.runner.Describable ` |-------------------------|----------------------| | ` abstract Description` | ` getDescription() ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#)From interface` org.junit.runner.manipulation.Filterable ` |------------------|-------------------------| | ` abstract void` | ` filter(Filter arg0) ` | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4#)From interface` org.junit.runner.manipulation.Sortable ` |------------------|-----------------------| | ` abstract void` | ` sort(Sorter arg0) ` | ||

## Public constructors

### AndroidJUnit4

```
AndroidJUnit4 (Class<?> klass, 
                AndroidRunnerParams runnerParams)
```

Constructs a new instance of the default runner

<br />

|                  Parameters                  ||
|----------------|------------------------------|
| `klass`        | `Class` <br />               |
| `runnerParams` | `AndroidRunnerParams` <br /> |

|          Throws          ||
|-----------------------|---|
| `InitializationError` |   |

### AndroidJUnit4

```
AndroidJUnit4 (Class<?> klass)
```

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

<br />

|       Parameters        ||
|---------|----------------|
| `klass` | `Class` <br /> |

|          Throws          ||
|-----------------------|---|
| `InitializationError` |   |

## Public methods

### filter

```
void filter (Filter filter)
```

<br />

<br />

|        Parameters         ||
|----------|-----------------|
| `filter` | `Filter` <br /> |

|           Throws            ||
|--------------------------|---|
| `NoTestsRemainException` |   |

### getDescription

```
Description getDescription ()
```

<br />

<br />

|        Returns        ||
|---------------|--------|
| `Description` | <br /> |

### run

```
void run (RunNotifier runNotifier)
```

<br />

<br />

|             Parameters              ||
|---------------|----------------------|
| `runNotifier` | `RunNotifier` <br /> |

### sort

```
void sort (Sorter sorter)
```

<br />

<br />

|        Parameters         ||
|----------|-----------------|
| `sorter` | `Sorter` <br /> |

-

  ## Classes

  - [AndroidJUnit4](https://developer.android.com/reference/android/support/test/runner/AndroidJUnit4)
  - [AndroidJUnitRunner](https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner)
  - [MonitoringInstrumentation](https://developer.android.com/reference/android/support/test/runner/MonitoringInstrumentation)
  - [MonitoringInstrumentation.ActivityFinisher](https://developer.android.com/reference/android/support/test/runner/MonitoringInstrumentation.ActivityFinisher)
  - [UsageTrackerFacilitator](https://developer.android.com/reference/android/support/test/runner/UsageTrackerFacilitator)