I am testing a class A that extends an abstract class B. Class B has a private member M which i want to set for testing.
- First part of the problem as i understand is to retrieve the class b from class A. For which i tried getSuperclass, which i think may not be the right way to do this. Although, I am able to retrieve the field desired using ````ReflectionTestUtils.findfield()``` but not able to use set field.
- Secondly when i try to set field (
ReflectionUtils.setField(field_M, B, M_to_be_set)
) it basically ends up in the following exception: java.lang.IllegalArgumentException: Can not set M field M to java.lang.Class I have tried to setField, but it is not able to find the field itself.
Thanks
Aucun commentaire:
Enregistrer un commentaire