Reputation: 165
I want to test execution of a block scheduled with View#postDelayed(Runnable, delay)
. So before asserting I call Robolectric.runUiThreadTasksIncludingDelayedTasks()
. But there the test code gets stuck, i.e. does not return.
I am sure that that delayed block is called if I run the app directly.
Is this a bug of the runUiThreadTasksIncludingDelayedTasks() or are there any other preconditions to use it?
Thx, Mick
Upvotes: 2
Views: 1300
Reputation: 5371
With Robolectric 3.8 you can use:
Robolectric.flushForegroundThreadScheduler()
This executes all runnables that have been enqueued on the foreground scheduler.
Upvotes: 1