RBusarow / Dispatch

Automatic CoroutineDispatcher injection and extensions for kotlinx.coroutines
https://rbusarow.github.io/Dispatch/
Apache License 2.0
137 stars 6 forks source link

[Bug] Late counter increment in IdlingDispatcher #646

Open Dimezis opened 5 months ago

Dimezis commented 5 months ago

https://github.com/RBusarow/Dispatch/blob/4b231ef18802c064375eee7a58326f8283794dcd/dispatch-android-espresso/src/main/java/dispatch/android/espresso/IdlingDispatcher.kt#L58

Since delegate.dispatch(context, runnable) generally don't execute the runnable immediately, you should increment the counter before constructing the Runnable, and not inside the Runnable itself. The current approach will increment the counter too late, and you can potentially get false positive idle notifications.