-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting executor (to work with Espresso) #1081
Comments
Does Espresso not have a way to wrap an |
Filed http://b.android.com/187510. See also http://stefanodacchille.github.io/blog/2014/04/05/wait-for-it/ and the gist https://gist.github.com/stefanodacchille/9995163 for ways to accomplish this. You should still be able to use the There's not much else to do here, this isn't really an Retrofit / OkHttp problem, just a shortcoming of the tools Espresso provides. |
if you're using Observables you can use .subscribeOn(Schedulers.from(AsyncTask.THREAD_POOL_EXECUTOR)) instead of .subscribeOn(Schedulers.io()) and everything works fine |
Or wrap the |
I just put this in my instrumentation test runner's RxJavaHooks.setOnIOScheduler(new Func1<Scheduler, Scheduler>() {
@Override
public Scheduler call(Scheduler scheduler) {
return Schedulers.from(AsyncTask.THREAD_POOL_EXECUTOR);
}
}); Where my Retrofit instance uses the IO scheduler by default, and so far it's working great. |
@shekibobo I had to put this code in the |
Back in
1.9
, in order to let Espresso know when the app was idle, as per this SO answer, you'd change theRestAdapter
's thread-pool executor with the same asAsyncTask
.It kinda seems more like a hackz than the actual way of doing it, so I think that's probably the reason the method
setExecutors()
is not part of the public API anymore on retrofit 2.0, which is nice.Now, we still need to make it work somehow with
Espresso
for our tests, right? Looking intoretrofit-mock
tests, I was able to see there's a class calledCallBehaviourAdapter
that goes like this:I think what would do the trick is the
newSingleThreadExecutor()
call but after trying for a couple of hours I found myself unable to accomplish it.Moreover, in the
SimpleMockService
sample there is the same call with aThreadFactoryBuilder
:Tried both but they didn't work. What am I missing?
The text was updated successfully, but these errors were encountered: