I am trying to get Volley working with Robolectric. I can see that my HTTP request is getting called, and parseNetworkResponse is getting called (I\'m sending a custom subclass
I solved that same problem by replacing the RequestQueue's ResponseDelivery with one that doesn't use the Looper.getMainLooper() but a new Executor. Example code:
public static RequestQueue newRequestQueueForTest(final Context context, final OkHttpClient okHttpClient) {
final File cacheDir = new File(context.getCacheDir(), "volley");
final Network network = new BasicNetwork(new OkHttpStack(okHttpClient));
final ResponseDelivery responseDelivery = new ExecutorDelivery(Executors.newSingleThreadExecutor());
final RequestQueue queue =
new RequestQueue(
new DiskBasedCache(cacheDir),
network,
4,
responseDelivery);
queue.start();
return queue;
}
Note: use Robolectric-2.2-SNAPSHOT, the previous version doesn't play well with Volley.
Hope this helps