title: Rxjava 2 on error is not called while unit testing
body: <p>Rxjava 2 on error is not called while unit testing . I am using kotlin with rxJava 2 .</p>
  
  <blockquote>
    <p>method</p>
  </blockquote>
  
  <pre><code>  @SuppressLint("CheckResult")
      override fun fetchFilms() {
          view.showLoader(true)
          disposable = getRetrofitInstance(false).create(API::class.java)
                  .fetchFilms()
                  .subscribeOn(io)
                  .observeOn(main)
                  .subscribeWith(object : DisposableObserver&lt;Response&gt;() {
                      override fun onComplete() {
                      }
  
                      override fun onNext(t: Response) {
                          println(t)
                          view.setAdapter(t?.results as List&lt;ResultsItem&gt;)
                          view.showLoader(false)
                      }
  
                      override fun onError(e: Throwable) {
                          e.printStackTrace()
                          view.showLoader(false)
                          view.showError(e.message.toString())                    }
  
                  })
  
  
      }
  </code></pre>
  
  <blockquote>
    <p>Test</p>
  </blockquote>
  
  <pre><code>@Test
      fun  fetchInvalidDataShouldThrowError(){
  
          `when`(api.fetchFilms()).thenReturn(Observable.error(IOException()))
     filmsPresenter.fetchFilms()
          val subscriber = TestSubscriber&lt;Response&gt;()
  
          subscriber.awaitTerminalEvent(5,TimeUnit.SECONDS)
  
          verify(filmsView, times(1)).showLoader(true)
          verify(filmsView).showError("t")
          verify(filmsView).showLoader(false)
  
  
      }
  </code></pre>