<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)航:
     
    主站蜘蛛池模板: 午夜视频在线观看免费完整版| 久久午夜无码免费| 成人毛片免费观看视频| 蜜芽亚洲av无码精品色午夜| 久久免费福利视频| 久久久久久亚洲精品成人| 午夜爽爽爽男女免费观看影院| 亚洲精品无码永久中文字幕| 一个人免费视频观看在线www| 亚洲午夜无码久久久久| 久久国产免费观看精品| 亚洲成a人片77777老司机| 最近最新高清免费中文字幕 | 亚洲电影在线免费观看| 亚洲视频欧洲视频| 日韩版码免费福利视频| 亚洲区日韩精品中文字幕| 亚洲av区一区二区三| 一区二区三区在线免费| 亚洲阿v天堂在线| 免费国产黄网站在线观看可以下载| 久久夜色精品国产噜噜噜亚洲AV| 中国人xxxxx69免费视频| 一本色道久久88亚洲精品综合| 国产成人高清精品免费软件| 九一在线完整视频免费观看| 亚洲国产精品无码成人片久久 | 亚洲小说图片视频| 日美韩电影免费看| 久久久精品国产亚洲成人满18免费网站 | 亚洲AV综合色一区二区三区| 99精品视频在线观看免费专区| 亚洲AV日韩综合一区尤物| 免费一级毛片不卡在线播放| 成人网站免费大全日韩国产 | 亚洲国产综合AV在线观看| 亚洲精品美女久久久久99小说| 国产在线国偷精品免费看| 亚洲精品国产专区91在线| 免费国产美女爽到喷出水来视频| 99久久99这里只有免费的精品|