public void testHandleRequestInternal() throws Exception {        List<OfferGroup> expectedList = new ArrayList<OfferGroup>();
        expectedList.add(null);
        expectedList.add(null);
        expectedList.add(null);
        expect(crmDao.findOfferGroups()).andReturn(expectedList);        replay(crmDao);        ModelAndView modelAndView = offerGroupOverviewController.handleRequestInternal(null, null);
        verify(crmDao);        Map model = modelAndView.getModel();
        List<OfferGroup> actualGroups = (List<OfferGroup>) model.get("offerGroups");
        assertEquals(expectedList, actualGroups);
        assertEquals(modelAndView.getViewName(), OfferGroupOverviewController.VIEWNAME);
    }

expect(crmDao.findOfferGroups()).andReturn(expectedList);
中的andReturn()得具体意思是什么?;
是crmDao.findOfferGroups()查询出来的值,还是expectedList预先设定的值

解决方案 »

  1.   

    expect(crmDao.findOfferGroups()).andReturn(expectedList);拿crmDao.findOfferGroups()的返回结果 和 expectedList相比较。。这个expectedList则是你自己创建的。就是你希望的返回结果。
      

  2.   

    这应该是设置期望值的意思,因为你的单元测试不是集成测试,不需要测试crmDao.findOfferGroups()的逻辑,所以只是返回了expectedList,这样保证了单元测试的独立性。
      

  3.   

    Do not quite understand?