Permalink
Browse files

Added basic documentation on using `XCTAssertRecordedElements`.

  • Loading branch information...
freak4pc authored and kzaher committed Aug 22, 2018
1 parent 11cca97 commit 8903bfc9b276790caceb71699668e45d39550a89
Showing with 20 additions and 0 deletions.
  1. +20 −0 Documentation/UnitTests.md
View
@@ -55,6 +55,26 @@ func testMap_Range() {
}
```
In the case of non-terminating sequences where you don't necessarily care about the event times, You may also use `RxTest`'s `XCTAssertRecordedElements` to assert specific elements have been emitted.
A terminating stop event (e.g. `completed` or `error`) will cause the test to fail.
```swift
func testElementsEmitted() {
let scheduler = TestScheduler(initialClock: 0)
let xs = scheduler.createHotObservable([
next(210, "RxSwift"),
next(220, "is"),
next(230, "pretty"),
next(240, "awesome")
])
let res = scheduler.start { xs.asObservable() }
XCTAssertRecordedElements(res.events, ["RxSwift", "is", "pretty", "awesome"])
}
```
## Testing operator compositions (view models, components)
Examples of how to test operator compositions are contained inside `Rx.xcworkspace` > `RxExample-iOSTests` target.

0 comments on commit 8903bfc

Please sign in to comment.