added in
version 1.1.0
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 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 |
From class
org.junit.rules.TestWatcher
Statement
|
apply(Statement arg0, Description arg1)
|
void
|
failed(Throwable arg0, Description arg1)
|
void
|
finished(Description arg0)
|
void
|
skipped(AssumptionViolatedException arg0, Description arg1)
|
void
|
skipped(AssumptionViolatedException arg0, Description arg1)
|
void
|
starting(Description arg0)
|
void
|
succeeded(Description arg0)
|
|
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
|
From interface
org.junit.rules.TestRule
abstract
Statement
|
apply(Statement arg0, Description arg1)
|
|
Public constructors
CountingTaskExecutorRule
CountingTaskExecutorRule ()
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. |
Protected methods
finished
void finished (Description description)
Parameters |
description |
Description |
onIdle
void onIdle ()
Called when the number of awaiting tasks reaches to 0.
starting
void starting (Description description)
Parameters |
description |
Description |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[]]