The method signature of the doInBackground method in AsyncTask.class looks like this:
protected Boolean doInBackground(MyObject... params);
And inside the test with reflection it looks like this:
try {
Method doInBackgroundMethod = asyncTaskInstance.getClass().getDeclaredMethod("doInBackground", MyObject[].class);
doInBackgroundMethod.setAccessible(true);
boolean success = (boolean) doInBackgroundMethod.invoke(asyncTaskInstance, myObjectInstance);
Assert.assertTrue(success);
} catch ...
but I get the following error:
java.lang.IllegalArgumentException: argument type mismatch, on line "doInBackgroundMethod.invoke(asyncTaskInstance, myObjectInstance);"
Do you have any idea how to solve this problem?
Aucun commentaire:
Enregistrer un commentaire