2.x: Clarify TestObserver.assertValueSet in docs and via tests#6152
2.x: Clarify TestObserver.assertValueSet in docs and via tests#6152akarnokd merged 2 commits intoReactiveX:2.xfrom
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.
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.
assertValuesIn(Collection<? extends T> expected)?
Stephan202
left a comment
There was a problem hiding this comment.
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.
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.
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.
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}.assertValueSetchecks 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.