title: Mockito not working when method start Observable
body: <p>im trying to test a presenter, but the test only pass when things are outside of Observable, my presenter:</p>
  
  <pre><code>class CompManCodePresenter @Inject constructor(val apiBag: ServiceModule.ApiBag, disposable: CompositeDisposable, scheduler: SchedulerProvider) : BasePresenter&lt;CompManCodeView&gt;(disposable, scheduler) {
  
      fun validateCompmanCode(code: String) {
          view?.showProgress()
          if (code.isEmpty()) {
              view?.emptyCode()
              view?.hideProgress()
          } else {
  
              val request = mutableMapOf&lt;String, Any?&gt;()
              request.put("code", code)
              disposable.add(
                      apiBag.apiMainFast.check_code(JWT.jwt_encrypted(request))
                      .subscribeOn(scheduler.io())
                      .observeOn(scheduler.ui())
                      .subscribe(
                              { result -&gt;
                                  view?.hideProgress()
                              },
                              { error -&gt;
                                  view?.hideProgress()
                                  view?.onError()
                              })
              )
          }
  
      }
  </code></pre>
  
  <p>rest api part:</p>
  
  <pre><code>@POST("v2/check-code")
  fun check_code(@Body body: JwtDataRequest): Observable&lt;SyncCompManAndDeviceResponse&gt;
  </code></pre>
  
  <p>test that works ok:</p>
  
  <pre><code>@Test
  fun test_code_empty() {
      val mockedResponse: Throwable = mock()
      val params = HashMap&lt;String, Any&gt;()
      val mockedRequest = JWT.jwt_encrypted(params)
  
      doReturn(Observable.just(mockedResponse)).`when`(api).check_code(mockedRequest)
      presenter.validateCompmanCode("")
  
      testScheduler.triggerActions()
  
      verify(view).showProgress()
      verify(view).emptyCode()
      verify(view).hideProgress()
  }
  </code></pre>
  
  <p><strong>test that is not working (it only run the .showProgress outside</strong> </p>
  
  <pre><code> @Test
      fun test_no_connection() {
  
          val mockedResponse: Throwable = mock()
          val params = HashMap&lt;String, Any&gt;()
          val mockedRequest = JWT.jwt_encrypted(params)
  
          doReturn(Observable.just(mockedResponse)).`when`(api).check_code(mockedRequest)
          presenter.validateCompmanCode("A")
  
          testScheduler.triggerActions()
          verify(view).showProgress()
          verify(view).hideProgress()
          verify(view).onError()
      }
  </code></pre>
  
  <p>my test class setup:</p>
  
  <pre><code>  private val view: CompManCodeView = mock()
      private lateinit var presenter: CompManCodePresenter
      private lateinit var testScheduler: TestScheduler
  
      val api:RestAPI = Mockito.mock(RestAPI::class.java, Mockito.RETURNS_DEEP_STUBS)
      val apiBag:ServiceModule.ApiBag = Mockito.spy(ServiceModule.ApiBag(api,api,api,api))
  
  
  
      @Before
      fun setUp() {
          MockitoAnnotations.initMocks(this);
          val compositeDisposable = CompositeDisposable()
          testScheduler = TestScheduler()
          val testSchedulerProvider = TestSchedulerProvider(testScheduler)
          presenter = CompManCodePresenter(apiBag, disposable = compositeDisposable, scheduler = testSchedulerProvider)
          presenter.attachView(view)
      }
  </code></pre>
  
  <p>no error show, the only thing that the test result show is this:</p>
  
  <pre><code>Wanted but not invoked:
  view.hideProgress();
  
  
  However, there were exactly 2 interactions with this mock:
  view.setPresenter(
      CompManCodePresenter@72ee5d84
  );
  -&gt; BasePresenter.attachView(BasePresenter.kt:13)
  
  view.showProgress();
  -&gt; at CompManCodePresenter.validateCompmanCode(CompManCodePresenter.kt:21)
  </code></pre>
  
  <p>im following this: <a href="https://github.com/burakeregar/KotlinRxMvpArchitecture" rel="nofollow noreferrer">https://github.com/burakeregar/KotlinRxMvpArchitecture</a></p>