vendredi 1 avril 2016

Reflection to mock object method in Android

public class myServer extents ImyServer.Stub {

  private ImyListener mListener = new ImyListener.Stub() {
        @Override
        public void myMethod(final int a) {
            Log.i(TAG, "Arg");
        }
    };
}

In this code I want to make mock call for myMethod() from AndroidTestCase. I was thinking to do it by java reflection. But this looks bit of tricky here. Need suggestion:

  1. How to use reflection and call myMethod() for this specific mListener.
  2. Any other way then reflection to do it?




Aucun commentaire:

Enregistrer un commentaire