Skip to content
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: improve BaseTestConsumer with awaitCount & timeout #5155

Merged
merged 2 commits into from
Mar 7, 2017

Conversation

akarnokd
Copy link
Member

@akarnokd akarnokd commented Mar 4, 2017

This PR enhances the timeout detection and reporting of the TestSubscriber/TestObserver base class BaseTestConsumer:

  • awaitCount(int atLeast [, Runnable waitStrategy [, timeout]]): wait until at least the given amount of onNext events have been observed or the upstream terminated.
  • Enhance awaitX methods to set a timeout flag.
  • Show the timeout! string in the assertion failures set by the awaitX methods.
  • Show the disposed! string in the assertion failures if the consumer has been cancelled/disposed.
  • assertTimeout and assertNoTimeout to assert explicitly after an awaitX method.
  • isTimeout and clearTimeout to check and clear the flag status.

In addition, the internal array that collects the items has been replaced with a new custom List implementation: VolatileSizeArrayList that makes sure size() is a volatile read and happens before the committing the size in another thread due to add(). (In theory, one shouldn't cast values() unconditionally to ArrayList anyway.)

@akarnokd akarnokd added this to the 2.1 milestone Mar 4, 2017
@codecov
Copy link

codecov bot commented Mar 4, 2017

Codecov Report

Merging #5155 into 2.x will decrease coverage by -0.07%.
The diff coverage is 99.06%.

@@             Coverage Diff              @@
##                2.x    #5155      +/-   ##
============================================
- Coverage     95.88%   95.82%   -0.07%     
- Complexity     5606     5645      +39     
============================================
  Files           620      621       +1     
  Lines         39856    39960     +104     
  Branches       5604     5610       +6     
============================================
+ Hits          38217    38291      +74     
- Misses          654      672      +18     
- Partials        985      997      +12
Impacted Files Coverage Δ Complexity Δ
...reactivex/internal/util/VolatileSizeArrayList.java 100% <100%> (ø) 30 <30> (?)
.../java/io/reactivex/observers/BaseTestConsumer.java 99.61% <98.18%> (+1.56%) 108 <16> (+15)
...rnal/subscriptions/ArrayCompositeSubscription.java 86.66% <0%> (-13.34%) 15% <0%> (-3%)
...rnal/subscribers/SinglePostCompleteSubscriber.java 87.17% <0%> (-12.83%) 13% <0%> (-2%)
...a/io/reactivex/processors/SerializedProcessor.java 87.23% <0%> (-10.64%) 25% <0%> (-3%)
...al/operators/observable/ObservableSampleTimed.java 90% <0%> (-6.67%) 3% <0%> (ø)
...ternal/operators/observable/ObservablePublish.java 89.18% <0%> (-6.31%) 9% <0%> (-1%)
...ernal/operators/flowable/FlowableFlatMapMaybe.java 89.55% <0%> (-5.98%) 2% <0%> (ø)
...rnal/subscriptions/DeferredScalarSubscription.java 93.84% <0%> (-4.62%) 27% <0%> (-1%)
.../internal/operators/maybe/MaybeTakeUntilMaybe.java 95.91% <0%> (-4.09%) 2% <0%> (ø)
... and 38 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 26eff79...030cac2. Read the comment docs.

@akarnokd akarnokd merged commit a86425a into ReactiveX:2.x Mar 7, 2017
@akarnokd akarnokd deleted the TestConsumerEnh304 branch March 7, 2017 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant