CountingTaskExecutorRule
open class CountingTaskExecutorRule : TestWatcher
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 | |
---|---|
<init>() 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. |
Public methods | |
---|---|
open Unit |
drainTasks(time: Int, timeUnit: TimeUnit!) Waits until all active tasks are finished. |
open Boolean |
isIdle() Returns false if there are tasks waiting to be executed, true otherwise. |
Protected methods | |
---|---|
open Unit |
finished(description: Description!) |
open Unit |
onIdle() Called when the number of awaiting tasks reaches to 0. |
open Unit |
starting(description: Description!) |
Public constructors
<init>
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.
Public methods
drainTasks
open fun drainTasks(
time: Int,
timeUnit: TimeUnit!
): Unit
Waits until all active tasks are finished.
Parameters | |
---|---|
time |
Int: The duration to wait |
timeUnit |
TimeUnit!: 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 |
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
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