Testing with RxBlocking

We will start a new test and create an Observable of 10, 20, and 30, as follows:

func testBlocking(){        let observableToTest = Observable.of(10, 20, 30)    }

Now we will define the result as equal to calling toBlocking() on the observable we created:

let result = observableToTest.toBlocking()

toBlocking() returns a blocking Observable to a straight array, as you can see here:

We will need to use the first method if we want to interrogate which is a throwing method, so we will wrap it in a do catch statement, and then we will add an AssertEquals statement if it is successful, as follows:

func testBlocking(){        let observableToTest ...

Get Reactive Programming with Swift 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.