我試圖捕捉與Robolectric HTTP請求的方法記號化方法發送請求到服務器,我只是想測試後發送HTTP請求: 如果我嘗試無法捕捉與robolectric
//Cardtest.java
Robolectric.setDefaultHttpResponse(200, "dummy");
card.tokenize(paymentHandler);
Robolectric.getSentHttpRequest(0);
的我有一個空數組錯誤
但我知道,因爲如果刪除第一行我有以下錯誤的請求被髮送:
Unexpected HTTP call POST
如果我把日誌語句看起來,我的成功塊永遠不會被要求一個http請求。
如何確保我的HTTP請求成功回調被調用。
(我已經嘗試Robolectric.runUiThreadTasksIncludingDelayedTasks();)
感謝
萬一你沒有行'Robolectric.getFakeHttpLayer ().interceptHttpRequests(false)' –
感謝它的工作! – Elie