Given a java.lang.reflect.Method object obtained through reflection, how can I test that this Method was called on a given object ?
Here is an example code :
MyClass obj = mock(MyClass.class);
injectInTestedObject(obj, testedObj);
String myMethodIWantToCheckName = retrieveMethodNameBySomeMeans();
Method myMethodIWantToCheck =
Arrays.asList(MyClass.class.getMethods())
.stream()
.filter(method -> method.getName().equals(myMethodIWantToCheckName))
.findFirst()
.get();
Now I'd like to check if myMethodIWantToCheck
was called on obj
.
Basically it's the same functionality as verify
from Mockito but without knowing the method at compile time.
Is there any way ? Any library already implementing this ?
Aucun commentaire:
Enregistrer un commentaire