mercredi 4 février 2015

Mocking Methods Invoked using reflection

I am invoking a method using reflection in one my classes using below way,



Method method = xyz.getClass().getDeclaredMethod("abc", new Class[] {});
Object ret = method.invoke(xyz, new Object[] {});


Now, in my test case of another class, I am trying to mock the above method but it gives me NoSuchMethodFoundError. I am not able to figure out the correct way of mocking this.


Question is how can we achieve mocking of this method which is invoked through reflection.






Aucun commentaire:

Enregistrer un commentaire