AndroidJUnit4

public final class AndroidJUnit4
extends Runner implements Filterable, Sortable

java.lang.Object
   ↳ org.junit.runner.Runner
     ↳ 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 enviroment. A custom runner can be provided by specifying the full class name in a 'android.junit.runner' system property.
  • Supports a per-test timeout - specfied via a 'timeout_msec' AndroidJUnitRunner argument.
  • Supports running tests on the application's UI Thread, for tests annotated with ERROR(/UiThreadTest).

Usage @RunWith(AndroidJUnit4.class)

Summary

Public constructors

AndroidJUnit4(Class<?> klass)

Public methods

void filter(Filter filter)
Description getDescription()
void run(RunNotifier runNotifier)
void sort(Sorter sorter)

Inherited methods

Public constructors

AndroidJUnit4

public AndroidJUnit4 (Class<?> klass)

Parameters
klass Class

Throws
InitializationError

Public methods

filter

public void filter (Filter filter)

Parameters
filter Filter

Throws
NoTestsRemainException

getDescription

public Description getDescription ()

Returns
Description

run

public void run (RunNotifier runNotifier)

Parameters
runNotifier RunNotifier

sort

public void sort (Sorter sorter)

Parameters
sorter Sorter