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

    主站蜘蛛池模板: 免费H网站在线观看的| 免费电影在线观看网站| 免费一级不卡毛片| 国产四虎免费精品视频| 亚洲日韩国产一区二区三区| 亚洲成AV人片在线观看无码 | 国产h肉在线视频免费观看| 永久免费AV无码网站在线观看| 亚洲成年看片在线观看| 亚洲国产精品久久久久网站 | 亚洲精品久久无码| 亚洲免费人成在线视频观看| 久久亚洲国产欧洲精品一| 国产免费AV片在线观看| 亚洲伊人tv综合网色| A国产一区二区免费入口| 成人黄页网站免费观看大全| 亚洲综合精品一二三区在线| 3d成人免费动漫在线观看| 亚洲一区二区三区乱码A| 最近中文字幕大全免费版在线 | 亚洲精品无AMM毛片| 四虎1515hm免费国产| youjizz亚洲| 成全视频在线观看免费| 亚洲色成人网一二三区| 久久青草免费91观看| 久久精品国产亚洲AV不卡| 亚洲精品国产高清在线观看| 亚洲男人av香蕉爽爽爽爽| 亚洲国产精品18久久久久久| 亚洲精品综合久久| 99爱在线观看免费完整版| 人人狠狠综合久久亚洲婷婷| 18女人腿打开无遮掩免费| 亚洲人成色77777在线观看| 免费99精品国产自在现线| 黄色毛片免费网站| 国产又长又粗又爽免费视频 | 亚洲午夜精品一区二区公牛电影院| 免费视频精品一区二区三区|