assertSubscribed() always passes no matter how many times a Flowable is subscribed to.
See original GitHub issueHi,
Perhaps I’ve misunderstood the purpose of this API method, but the javadoc for assertSubscribed()
that it should only pass if the Flowable has been subscribed to. However it seems to pass for me even if I don’t subscribe, eg the following passes:
Flowable.fromArray(1, 2).test().assertSubscribed();
It also suggests that it will pass if you only subscribe once, so the following test case should also fail, but seems to pass:
final Flowable<Integer> flowable = Flowable.fromArray(1, 2);
flowable.subscribe();
flowable.subscribe();
flowable.test().assertSubscribed();
I’ve tested this in both rxjava 2.1.1 and 2.0.1.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Eager subscription - RxJava FAQ - Tomasz Nurkiewicz
This means no matter how heavy or long-running logic you place inside ... Even worse, even though eager() returns a Flowable it will...
Read more >RxJava2 : How to test an observable is subscribed with ...
test() creates a subscription to the observable giving the following erroneous tests. // fixme: test passes but TestObservable is always true ...
Read more >Testing RxJava code made easy - Medium
We want to assert that an Observable is being subscribed to, emits one value, completes and has no errors. Observable.just(1) .test() .
Read more >TestObserver (RxJava Javadoc 3.1.5) - ReactiveX
Returns true if this TestObserver received a subscription. boolean, isDisposed(). Returns true if this test consumer was cancelled/disposed.
Read more >4. Applying Reactive Programming to Existing Applications
For the time being, notice how we can lazily call bestSeller() without ... As long as no one subscribes to Observable<Ticket> , RxJava...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Calling test() calls subscribe automatically and returns the TestSubscriber. This would only then return false in this case of a broken Flowable that never called the onSubscribe method of the Subscriber.
On Fri, Jul 7, 2017 at 1:23 PM Richard Warburton notifications@github.com wrote:
Hi gents,
Thanks for your replies. I was aware of the big picture stuff here but I hadn’t put the implications together in my own mind. Thanks for clarifying the situation. I think the javadoc change you suggested would help confusion around the “subscribe once” aspect as well. I’ll close this issue.
regards,
Richard