title: Unit testing Rxjava observables that have a delay
body: <p>I want to be able to unit test an <code>Observable</code> that has a delayed emission, but without actually waiting for the delay time. Is there a way to do this? </p>
  
  <p>I'm currently using a CountDownHatch to delay the assert, and that works fine, but increases the test run time.</p>
  
  <p>Example:</p>
  
  <pre><code>val myObservable: PublishSubject&lt;Boolean&gt; = PublishSubject.create&lt;Boolean&gt;()
  fun myObservable(): Observable&lt;Boolean&gt; = myObservable.delay(3, TimeUnit.SECONDS)
  
  @Test
  fun testMyObservable() {
      val testObservable = myObservable().test()
      myObservable.onNext(true)
  
      // val lock = CountDownLatch(1)
      // lock.await(3100, TimeUnit.MILLISECONDS)
      testObservable.assertValue(true)
  }
  </code></pre>