executorservice - Android: How to use IdlingResource to wait for background tasks (Espresso) -
i ask not implement last week. implementing espresso tests when found out serious problem.
sometimes tests succeeded not always. issue app has several async tasks have wait before checking test conditions. usually, espresso waits main thread tasks.
i using executors generate new threads, this:
executor = executors.newfixedthreadpool(max_threads); and check if idle, i'm using this:
boolean isitidle = executor.isterminated() || executor.isshutdown(); obviously, solution doesn't work. appreciated, thank in advance.
i forgot updating post solution have implemented. :(
my solution calling executor shutdown everytime need know when executor goes idling state. so, changed checking method in way:
executor.shutdown(); boolean isitidle = executor.isterminated(); calling executor.shutdown() makes possible executor.isterminated() method useful. however, should noted have consider shutdown state (executor.isshutdown()) when need generate new thread.
i hope someone! ;)
Comments
Post a Comment