How to test PublishSubject in RxSwift
Issue #218
- RxBlocking does not work with Variable and PublishSubject, see https://github.com/ReactiveX/RxSwift/blob/0b66f666ba6955a51cba1ad530311b030fa4db9c/Tests/RxSwiftTests/Observable%2BSubscriptionTest.swift#L165
Use homemade Recorder
1 | class Recorder<T> { |
Then test
1 | final class BookViewModelTests: XCTestCase { |
Need to use great timeout
value as DispatchQueue
is not guaranteed to be precise, a block needs to wait for the queue to be empty before it can be executed
Make expectation
less cumbersome
1 | extension XCTestCase { |