CountingTaskExecutorRule

open class CountingTaskExecutorRule
kotlin.Any
   ↳ androidx.arch.core.executor.testing.CountingTaskExecutorRule

A JUnit Test Rule that swaps the background executor used by the Architecture Components with a different one which counts the tasks as they are start and finish.

You can use this rule for your host side tests that use Architecture Components.

Summary

Public constructors

Public methods
open Boolean

Returns false if there are tasks waiting to be executed, true otherwise.

open Unit
drainTasks(time: Int, timeUnit: TimeUnit!)

Waits until all active tasks are finished.

Protected methods
open Unit
finished(description: Description!)

open Unit

Called when the number of awaiting tasks reaches to 0.

open Unit
starting(description: Description!)

Public constructors

<init>

CountingTaskExecutorRule()

Public methods

isIdle

open fun isIdle(): Boolean

Returns false if there are tasks waiting to be executed, true otherwise.

Return
Boolean: False if there are tasks waiting to be executed, true otherwise.

See Also

drainTasks

open fun drainTasks(time: Int, timeUnit: TimeUnit!): Unit

Waits until all active tasks are finished.

Parameters
time Int: The duration to wait
timeUnit Int: The time unit for the time parameter
Exceptions
InterruptedException If thread is interrupted while waiting
TimeoutException If tasks cannot be drained at the given time

Protected methods

finished

protected open fun finished(description: Description!): Unit

onIdle

protected open fun onIdle(): Unit

Called when the number of awaiting tasks reaches to 0.

See Also

starting

protected open fun starting(description: Description!): Unit