-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2.x: Add assertValuesOnly to BaseTestConsumer. #5568
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1439,4 +1439,47 @@ public void withTag() { | |
assertTrue(ex.toString(), ex.toString().contains("testing with item=2")); | ||
} | ||
} | ||
|
||
@Test | ||
public void assertValuesOnlyWantsOnlyValues() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wants? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could just completely rename it to assertValuesOnly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sgtm |
||
TestObserver<Integer> to = TestObserver.create(); | ||
to.onSubscribe(Disposables.empty()); | ||
to.assertValuesOnly(); | ||
|
||
to.onNext(5); | ||
to.assertValuesOnly(5); | ||
|
||
to.onNext(-1); | ||
to.assertValuesOnly(5, -1); | ||
} | ||
|
||
@Test | ||
public void assertValuesOnlyThrowsWhenCompleted() { | ||
TestObserver<Integer> to = TestObserver.create(); | ||
to.onSubscribe(Disposables.empty()); | ||
|
||
to.onComplete(); | ||
|
||
try { | ||
to.assertValuesOnly(); | ||
fail(); | ||
} catch (AssertionError ex) { | ||
// expected | ||
} | ||
} | ||
|
||
@Test | ||
public void assertValuesOnlyThrowsWhenErrored() { | ||
TestObserver<Integer> to = TestObserver.create(); | ||
to.onSubscribe(Disposables.empty()); | ||
|
||
to.onError(new TestException()); | ||
|
||
try { | ||
to.assertValuesOnly(); | ||
fail(); | ||
} catch (AssertionError ex) { | ||
// expected | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not super important, but if you have time let's add test that verifies that method fails if expected value was emitted :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean was not emitted right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant "unexpected", sorry :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Experimental
&@since 2.1.4 - experimental
missing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. Forgot that.