本文介紹了Mockito:使用泛型參數(shù)進行驗證的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
使用 Mockito,我可以做到以下幾點:
With Mockito I can do the following:
verify(someService).process(any(Person.class));
但是,如果 process
采用 Collection
代替,我該怎么寫呢?無法弄清楚如何正確編寫它.只是遇到語法錯誤...
But how do I write this if process
takes a Collection<Person>
instead? Can't figure out how to write it correctly. Just getting syntax errors...
推薦答案
試試:
verify(someService).process(Matchers.<Collection<Person>>any());
實際上,當我鍵入 any()
時,IntelliJ 會自動建議此修復(fù)程序...不幸的是,在這種情況下您不能使用靜態(tài)導(dǎo)入.
Actually, IntelliJ automatically suggested this fix when I typed any()
... Unfortunately you cannot use static import in this case.
這篇關(guān)于Mockito:使用泛型參數(shù)進行驗證的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!