java.lang.Object | ||
↳ | io.reactivex.observers.BaseTestConsumer<T, U extends io.reactivex.observers.BaseTestConsumer<T, U>> | |
↳ | io.reactivex.observers.TestObserver<T> |
An Observer that records events and allows making assertions about them.
You can override the onSubscribe, onNext, onError, onComplete, onSuccess and cancel methods but not the others (this is by design).
The TestObserver implements Disposable for convenience where dispose calls cancel.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
TestObserver()
Constructs a non-forwarding TestObserver.
| |||||||||||
TestObserver(Observer<? super T> actual)
Constructs a forwarding TestObserver.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
final TestObserver<T> |
assertNotSubscribed()
Assert that the onSubscribe method hasn't been called at all.
| ||||||||||
final TestObserver<T> |
assertOf(Consumer<? super TestObserver<T>> check)
Run a check consumer with this TestObserver instance.
| ||||||||||
final TestObserver<T> |
assertSubscribed()
Assert that the onSubscribe method was called exactly once.
| ||||||||||
final void |
cancel()
Cancels the TestObserver (before or after the subscription happened).
| ||||||||||
static <T> TestObserver<T> |
create(Observer<? super T> delegate)
Constructs a forwarding TestObserver.
| ||||||||||
static <T> TestObserver<T> |
create()
Constructs a non-forwarding TestObserver.
| ||||||||||
final void |
dispose()
Dispose the resource, the operation should be idempotent.
| ||||||||||
final boolean |
hasSubscription()
Returns true if this TestObserver received a subscription.
| ||||||||||
final boolean |
isCancelled()
Returns true if this TestObserver has been cancelled.
| ||||||||||
final boolean |
isDisposed()
Returns true if this resource has been disposed.
| ||||||||||
void |
onComplete()
Called once the deferred computation completes normally.
| ||||||||||
void |
onError(Throwable t)
Called once if the deferred computation 'throws' an exception.
| ||||||||||
void |
onNext(T t)
Provides the Observer with a new item to observe.
| ||||||||||
void |
onSubscribe(Disposable s)
Called once by the Completable to set a Disposable on this instance which
then can be used to cancel the subscription at any time.
| ||||||||||
void |
onSuccess(T value)
Notifies the MaybeObserver with one item and that the
Maybe has finished sending
push-based notifications. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Constructs a non-forwarding TestObserver.
Constructs a forwarding TestObserver.
actual | the actual Observer to forward events to |
---|
Assert that the onSubscribe method hasn't been called at all.
Run a check consumer with this TestObserver instance.
check | the check consumer to run |
---|
Assert that the onSubscribe method was called exactly once.
Cancels the TestObserver (before or after the subscription happened).
This operation is thread-safe.
This method is provided as a convenience when converting Flowable tests that cancel.
Constructs a forwarding TestObserver.
delegate | the actual Observer to forward events to |
---|
Constructs a non-forwarding TestObserver.
Dispose the resource, the operation should be idempotent.
Returns true if this TestObserver received a subscription.
Returns true if this TestObserver has been cancelled.
Returns true if this resource has been disposed.
Called once the deferred computation completes normally.
Called once if the deferred computation 'throws' an exception.
t | the exception, not null. |
---|
Provides the Observer with a new item to observe.
The Observable
may call this method 0 or more times.
The Observable
will not call this method again after it calls either onComplete()
or
onError(Throwable)
.
t | the item emitted by the Observable |
---|
Called once by the Completable to set a Disposable on this instance which then can be used to cancel the subscription at any time.
s | the Disposable instance to call dispose on for cancellation, not null |
---|
Notifies the MaybeObserver with one item and that the Maybe
has finished sending
push-based notifications.
The Maybe
will not call this method if it calls onError(Throwable)
.
value | the item emitted by the Maybe |
---|