jeudi 14 décembre 2017

Android Unit Test AsyncTask.execute not called

public void get(String url, boolean auth, Callback callback) {
        Logger.e("RequestManager : get " + url);
        if (callback == null) {
            Logger.e("RequestManager: Callback = null;");
        } else {
            Logger.e("RequestManager: Callback ! = null");
        }
        AR request = new AR(url, callback, methodGet, auth, null);
        Logger.e("AR execute");
        request.execute();
        Logger.e("AR after execute");
    }

Somewhere in my code i have this functions. Logs show me thats all parameters are ok. But when i run test with this function :

request.execute() not work.

So i cant get results from asynctask : how i launch it in TestFile header :

@RunWith(MockitoJUnitRunner.class)
public class UnitTest {

function

@Test
    public void startAudioAds() {
        System.out.println("get request with asynctask);
        MyClassInstance.get(param1,param2,param3,null);
    }

Constructor of AR (AR - its AsyncTask class) is calling ok. Every parammeter is ok onPostExecute,doOnBackground, onPreExceute - not calling. Any Help ?

Aucun commentaire:

Enregistrer un commentaire