<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 閱讀(544) 評論(0)  編輯  收藏 所屬分類: Unit Test


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 美女黄色毛片免费看| 男女污污污超污视频免费在线看| 嫖丰满老熟妇AAAA片免费看| 亚洲精品无码成人| 中文字幕亚洲综合久久菠萝蜜 | 亚洲自偷自拍另类图片二区| 拍拍拍又黄又爽无挡视频免费| 日韩在线观看免费| 亚洲精品福利网泷泽萝拉| 国产成人免费a在线视频app| 无码人妻一区二区三区免费看| 亚洲天然素人无码专区| 亚洲熟妇无码另类久久久| 青苹果乐园免费高清在线| 国产日韩精品无码区免费专区国产| 亚洲午夜电影在线观看高清 | 成人免费毛片内射美女APP| 特a级免费高清黄色片| 亚洲激情电影在线| 亚洲日韩在线中文字幕第一页 | 久久这里只有精品国产免费10| 成全视成人免费观看在线看| 亚洲国产日韩综合久久精品| 亚洲桃色AV无码| 成人永久免费福利视频网站| 最近中文字幕免费2019| 久青草国产免费观看| 亚洲第一成年网站视频| 亚洲视频在线一区| 亚洲中文字幕无码一区二区三区 | 亚洲AV无码不卡在线播放| 国产成人免费A在线视频| 精品免费久久久久久久| 少妇性饥渴无码A区免费| 精品在线免费视频| 亚洲中文字幕无码爆乳| 亚洲老熟女@TubeumTV| 亚洲AV无码不卡在线播放| 国产亚洲色视频在线| 亚洲成av人在片观看| 成人国产mv免费视频|