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

Rx{Java,RxAndroid}Plugins with UnitTesting

Rx{Java,RxAndroid}Plugins with UnitTesting

http://connpass.com/event/27156/
TestSubscriber / TestScheduler / TestSubject / RxJavaPlugins / RxAndroidPlugins

Masayuki Izumi

March 16, 2016
Tweet

More Decks by Masayuki Izumi

Other Decks in Programming

Transcript

  1. > Masayuki IZUMI a.k.a. @izumin5210 > Rekimoto Lab. at the

    Univ. of Tokyo > Strobo, Inc. / Wantedly, Inc. > Rubyist / Androider / {Java,Type}Scripter
  2. &YBNQMF TestSubscriber<User> subscriber = new TestSubscriber<>(); TestScheduler scheduler = new

    TestScheduler(); PublishSubject<User> subject = PublishSubject.create(); subject.buffer(3000, TimeUnit.MILLISECONDS, scheduler) .subscribe(subscriber); subject.onNext(new User("Alice")); subscriber.assertValueCount(0); scheduler.advanceTimeBy(3000, TimeUnit.MILLISECONDS); subscriber.assertValueCount(1);
  3. &YBNQMF TestSubscriber<User> subscriber = new TestSubscriber<>(); TestScheduler scheduler = new

    TestScheduler(); PublishSubject<User> subject = PublishSubject.create(); subject.buffer(3000, TimeUnit.MILLISECONDS, scheduler) .subscribe(subscriber); subject.onNext(new User("Alice")); subscriber.assertValueCount(0); scheduler.advanceTimeBy(3000, TimeUnit.MILLISECONDS); subscriber.assertValueCount(1);
  4. &YBNQMF TestSubscriber<User> subscriber = new TestSubscriber<>(); TestScheduler scheduler = new

    TestScheduler(); PublishSubject<User> subject = PublishSubject.create(); subject.buffer(3000, TimeUnit.MILLISECONDS, scheduler) .subscribe(subscriber); subject.onNext(new User("Alice")); subscriber.assertValueCount(0); scheduler.advanceTimeBy(3000, TimeUnit.MILLISECONDS); subscriber.assertValueCount(1);
  5. &SSPSIBOEMFS RxJavaPlugins.getInstance() .registerErrorHandler(new RxJavaErrorHandler() { @Override public void handleError(Throwable e)

    { super.handleError(e); } @Override protected String render(Object item) throws InterruptedException { return super.render(item); } });