UiThreadTestRule


class UiThreadTestRule : TestRule


This rule allows the test method annotated with UiThreadTest to execute on the application's main thread (or UI thread).

Note, methods annotated with Before and After will also be executed on the UI thread.

See also
UiThreadTest

if you need to switch in and out of the UI thread within your method.

Summary

Public constructors

Public functions

Statement!
apply(base: Statement!, description: Description!)
Unit
runOnUiThread(runnable: Runnable!)

Helper method for running part of a method on the UI thread.

Protected functions

Boolean

Public constructors

UiThreadTestRule

UiThreadTestRule()

Public functions

apply

fun apply(base: Statement!, description: Description!): Statement!

runOnUiThread

fun runOnUiThread(runnable: Runnable!): Unit

Helper method for running part of a method on the UI thread.

Note: In most cases it is simpler to annotate the test method with UiThreadTest.

Use this method if you need to switch in and out of the UI thread within your method.

Parameters
runnable: Runnable!

runnable containing test code in the run method

See also
UiThreadTest

Protected functions

shouldRunOnUiThread

protected fun shouldRunOnUiThread(description: Description!): Boolean