I tried to mock class with method annotations via JMockit, and discovered that no method annotations were retrievable via reflection. Field annotations work as intendet. Do I miss something?
Mocking:
@Test
public void testThatSetterInjectionIsBombedProperlyOnNonAssignability(@Mocked final WithInjectableMethods injectable,
@Mocked final TextView textView,
@Mocked final Button button) {
Class in question:
class WithInjectableMethods extends Activity {
private android.view.View asView;
private Button button;
// shall be left alone
private View notInjected = null;
// shall be injected
@InjectView(id = 239)
private void setAsView(View asView) {
this.asView = asView;
}
@InjectView(id = 555)
public void setButton(Button button) {
this.button = button;
}
public void setNotInjected(View notInjected) {
this.notInjected = notInjected;
}
I was able to work around:
@Mocked(methods = {"setAsView", "setButton", "notInjected"}, inverse = true) final WithInjectableMethods injectable,
I also started issue on jmockit, it was acepted and fix is promissed in the next release: