<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

    主站蜘蛛池模板: 114级毛片免费观看| 亚洲av无一区二区三区| 成人免费av一区二区三区| 免费大黄网站在线观看| MM1313亚洲国产精品| 国产成人涩涩涩视频在线观看免费| 亚洲av无码不卡久久| 国产福利在线观看免费第一福利| 亚洲国产精品综合一区在线 | 亚洲日韩国产二区无码| 青青草国产免费久久久91| 激情综合亚洲色婷婷五月| 国产精品爱啪在线线免费观看| 亚洲自偷精品视频自拍| 四虎永久在线观看免费网站网址| 亚洲a级片在线观看| 成人性生活免费视频| 国产亚洲精品精品精品| 黑人大战亚洲人精品一区| 免费在线观看一级片| 亚洲三级在线播放| 免费看男女下面日出水视频 | 激情婷婷成人亚洲综合| 久久亚洲国产精品123区| 无码人妻一区二区三区免费n鬼沢| 亚洲色图视频在线观看| 日韩视频在线免费观看| 国产乱子伦精品免费视频| 亚洲色图.com| 四虎永久成人免费| 99视频免费播放| 亚洲爆乳少妇无码激情| 亚洲线精品一区二区三区影音先锋| 成全在线观看免费观看大全 | 99热这里只有精品免费播放| 亚洲欧洲国产成人精品| 四虎成人免费影院网址| 91精品全国免费观看青青| 亚洲成a人片毛片在线| 免费在线观看污网站| 久久精品电影免费动漫|