Unit Testing While Using RxJava 2

6427501df5c44488da4cae07055897fe?s=47 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

6427501df5c44488da4cae07055897fe?s=128

Elvis Lin

December 27, 2017
Tweet

Transcript

  1. 2.
  2. 9.

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

    if (Time.now() - startTime > waitLimit) throw new TestTimeoutException(); sleep (pollingInterval); } readResult(); assertResult();
  3. 10.

    在 RxJava 實作 Unit Test • 拆解 Observable 跟 Observer

    • 使⽤用 TestObserver 與 TestScheduler • 使⽤用 Interface 隔離實作
  4. 15.

    參參考資料 • 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