-
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: Clarify TestObserver.assertValueSet in docs and via tests #6152
Conversation
* asynchronous streams. | ||
* <p> | ||
* To ensure that only the expected items have been received, no more and no less, in any order, | ||
* apply {@link #assertValueCount(int)} with {@code expected.size()}. |
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.
I guess ideally method name would indicate that by using a word like contains
, maybe add it to 3.x list of changes?
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.
assertValuesIn(Collection<? extends T> expected)
?
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.
Posted #6153.
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.
One grammar nit and one question :)
Thanks for the rapid response!
* Assert that the TestObserver/TestSubscriber received only the specified values in any order. | ||
* <p>This helps asserting when the order of the values is not guaranteed, i.e., when merging | ||
* Assert that the TestObserver/TestSubscriber received only items that are in the specified | ||
* collection as well irrespective of the order they were received. |
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.
collection as well irrespective of the order they were received.
->
collection as well, irrespective of the order in which they were received.
* asynchronous streams. | ||
* <p> | ||
* To ensure that only the expected items have been received, no more and no less, in any order, | ||
* apply {@link #assertValueCount(int)} with {@code expected.size()}. |
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.
As-is this method "ignores" duplicates, while assertValueCount
doesn't. If a user wishes to assert that all values were received while allowing for duplicates, they could to .distinct().test()
. Is this the preferred approach, and if so, is it worth documenting that too? (Maybe have an example of that in the test below?)
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.
The aim is to provide some typical set of assertions with TestObserver
. You can always modulate the input flow or simply enumerate contents of the TestObserver
manually. I usually try to minimize the cases where additional operators are mentioned in the javadocs because it triggers "what about when using X" type of comments.
Codecov Report
@@ Coverage Diff @@
## 2.x #6152 +/- ##
===========================================
- Coverage 98.26% 98.2% -0.07%
+ Complexity 6199 6197 -2
===========================================
Files 667 667
Lines 44857 44857
Branches 6213 6213
===========================================
- Hits 44078 44051 -27
- Misses 246 263 +17
- Partials 533 543 +10
Continue to review full report at Codecov.
|
Clarify that
{TestObserver|TestSubscriber}.assertValueSet
checks for all received items to be in the provided set, but that set can contain additional elements that could have been received. Unit tests have been added to demonstrate the expected behavior.Resolves: #6151.