belongs to Maven artifact android.arch.core:core-testing:1.1.1
CountingTaskExecutorRule
public
class
CountingTaskExecutorRule
extends TestWatcher
java.lang.Object | ||
↳ | org.junit.rules.TestWatcher | |
↳ | android.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 | |
---|---|
CountingTaskExecutorRule()
|
Public methods | |
---|---|
void
|
drainTasks(int time, TimeUnit timeUnit)
Waits until all active tasks are finished. |
boolean
|
isIdle()
Returns false if there are tasks waiting to be executed, true otherwise. |
Protected methods | |
---|---|
void
|
finished(Description description)
|
void
|
onIdle()
Called when the number of awaiting tasks reaches to 0. |
void
|
starting(Description description)
|
Inherited methods | |
---|---|
Public constructors
Public methods
drainTasks
void drainTasks (int time, TimeUnit timeUnit)
Waits until all active tasks are finished.
Parameters | |
---|---|
time |
int : The duration to wait |
timeUnit |
TimeUnit : The time unit for the time parameter |
Throws | |
---|---|
InterruptedException |
If thread is interrupted while waiting |
TimeoutException |
If tasks cannot be drained at the given time |
isIdle
boolean isIdle ()
Returns false if there are tasks waiting to be executed, true otherwise.
Returns | |
---|---|
boolean |
False if there are tasks waiting to be executed, true otherwise. |
See also:
Protected methods
finished
void finished (Description description)
Parameters | |
---|---|
description |
Description |
onIdle
void onIdle ()
Called when the number of awaiting tasks reaches to 0.
See also:
starting
void starting (Description description)
Parameters | |
---|---|
description |
Description |