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 class Recorder<T> { var items = [T]() let bag = DisposeBag() func on(arraySubject: PublishSubject<[T]>) { arraySubject.subscribe(onNext: { value in self.items = value }).disposed(by: bag) } func on(valueSubject: PublishSubject<T>) { valueSubject.subscribe(onNext: { value in self.items.append(value) }).disposed(by: bag) } } Then test final class BookViewModelTests: XCTestCase { func testBooks() throws { let expectation = self.expectation(description: #function) let recorder = Recorder<Book>() let viewModel = BookViewModel(bookClient: MockBookClient()) recorder....