How to mock Completable’s delay() in RxJava?

I am using RxJava3. Its Completable has one non-static method delay(long time, TimeUnit unit).
I want to mock this delay method in my Unit Test by skipping it directly or delay a very short time, e.g. 1ms. Is it possible?
(It looks like cannot mock Completable, as it will impact the normal functionality. )

  • I figured out one workaround by myself. Make the first parameter long time got from one method, e.g. xxx.delay(getDelayTime(), TimeUnit.MILLISECONDS). Then we can mock getDelayTime()

    – 

Leave a Comment