2

JMockitを介してメソッドアノテーションを使用してクラスをモックしようとしましたが、リフレクションを介してメソッドアノテーションを取得できないことがわかりました。フィールド注釈は意図的に機能します。私は何かが恋しいですか?

モック:

    @Test
public void testThatSetterInjectionIsBombedProperlyOnNonAssignability(@Mocked final WithInjectableMethods injectable,
                                                                      @Mocked final TextView textView,
                                                                      @Mocked final Button button) {

問題のクラス:

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;
    }
4

1 に答える 1

2

私は回避することができました:

   @Mocked(methods = {"setAsView", "setButton", "notInjected"}, inverse = true) final WithInjectableMethods injectable,

私もjmockitで問題を開始しましたが、それは受け入れられ、次のリリースで修正が約束されています。

http://code.google.com/p/jmockit/issues/detail?id=184

于 2011-09-12T06:41:04.947 に答える