Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Unit Testing While Using RxJava 2

Elvis Lin
December 27, 2017

Unit Testing While Using RxJava 2

Introduce how to write a unit testing while you use RxJava 2 in your program

Elvis Lin

December 27, 2017
Tweet

More Decks by Elvis Lin

Other Decks in Programming

Transcript

  1. 非同步的單元測試 — Pooling doAsyncCall(); startTime = Time.now(); while (!responseReceived) {

    if (Time.now() - startTime > waitLimit) throw new TestTimeoutException(); sleep (pollingInterval); } readResult(); assertResult();
  2. 在 RxJava 實作 Unit Test • 拆解 Observable 跟 Observer

    • 使⽤用 TestObserver 與 TestScheduler • 使⽤用 Interface 隔離實作
  3. 參參考資料 • Asynchronous Behavior
 http://teddy-chen-tw.blogspot.tw/ 2012/12/3asynchronous-behavior.html • Testing RxJava2
 https://www.infoq.com/articles/Testing-

    RxJava2 • Testing asynchronous RxJava code using Mockito
 https://medium.com/@fabioCollini/testing- asynchronous-rxjava-code-using- mockito-8ad831a16877