<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    thinking

    one platform thousands thinking

    Mock void method

    I have a method that returns void in a class that is a dependency of the class I want to test.

    This class is huge and I'm only using this single method from it. I need to replace the implementation of this method for the test as I want it to do something different and I need to be able to access the parameters this method receives.

    I cannot find a way of doing this in EasyMock. I think I know how to do it with Mockito by using doAnswer but I don't want to add another library unless absolutely necessary.


    If I understand what you want to do correctly, you should be able to use andAnswer():

    mockObject.someMethod(eq(param1), eq(param2);

    expectLastCall().andAnswer(newIAnswer(){
        publicObject answer(){
            
    //supply your mock implementation here

            SomeClass arg1 
    =(SomeClass) getCurrentArguments()[0];

            AnotherClass arg2 
    =(AnotherClass) getCurrentArguments()[1];

            arg1.doSomething(blah);

            
    //return the value to be returned by the method (null for void)

            returnnull;

        }

    });

    posted on 2010-04-21 18:23 lau 閱讀(542) 評論(0)  編輯  收藏 所屬分類: Unit Test

    主站蜘蛛池模板: 麻豆精品国产免费观看| 亚洲免费观看在线视频| 最近中文字幕免费mv视频7| 爱丫爱丫影院在线观看免费 | 鲁大师在线影院免费观看 | 日本成人在线免费观看| 亚洲免费福利视频| 可以免费观看的毛片| 免费精品久久久久久中文字幕 | 中国xxxxx高清免费看视频| 国产一级a毛一级a看免费人娇| 国产精品亚洲一区二区在线观看| 亚洲免费视频网址| 亚洲欧洲日本精品| 久久精品国产亚洲AV无码麻豆 | 久久精品视频免费播放| 国产成人精品免费大全| 菠萝菠萝蜜在线免费视频| 亚洲中文无码mv| jiz zz在亚洲| 亚洲色丰满少妇高潮18p| 亚洲H在线播放在线观看H| 亚洲国语在线视频手机在线| 亚洲人成在线观看| 亚洲一级二级三级不卡| 亚洲AV无码专区国产乱码电影| 亚洲精品乱码久久久久久中文字幕| 亚洲人成色7777在线观看不卡| 亚洲av区一区二区三| 免费一级成人毛片| 亚洲成?v人片天堂网无码| 国产一级淫片a免费播放口之| 国产精品国产自线拍免费软件| 日本a级片免费看| 免费观看国产小粉嫩喷水| 免费一级大黄特色大片| 久久久久亚洲爆乳少妇无| 黑人大战亚洲人精品一区| 亚洲精品国产美女久久久| 亚洲国产综合91精品麻豆| 亚洲福利视频网站|