亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

帶有自動裝配注釋的 AbstractClass Junit

帶有自動裝配注釋的 AbstractClass Junit

牛魔王的故事 2021-09-15 17:31:00
我有一個抽象類,它在其中使用 @Autowired 注釋。我正在嘗試使用 MockitoJUnitRunner 編寫 junit。@RunWith(MockitoJUnitRunner.class)public class AbstractAdminSearchServiceTest { @Mock private IUPSService upsService; Map<String,String> map;  @Before    public void setUp() {      map=new HashMap<>();    } @Test public void testSearchAdministratorsForIndividualNotification(){     AbstractAdminSearchService  mock=Mockito.mock(AbstractAdminSearchService.class,             Mockito.CALLS_REAL_METHODS);     when(upsService.getUsersProfile(buildUserIds(),new String[] {})).thenReturn(map);     mock.searchAdministratorsForIndividualNotification(buildSolrUsers(), ""); }@Mock 不起作用,并且“upsService”沒有被嘲笑。結果,當實際調用 upsService.getUsersProfile 時,我收到 NullpointerException。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 201 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號