mockito

    1熱度

    2回答

    我有一個指標收集器,它將數據存儲在InfluxDB上,我想測試存儲這些指標的方法。我正在嘗試,但我無法嘲笑InfluxDB客戶端。我不想在測試環境中指出一個真實的InfluxDB。 到目前爲止我所取得的一切都是一些「空指針異常」,並且連接被拒絕。 這是我的測試(使用TestNG)。我究竟做錯了什麼? @Test public void validateMetrics() {

    0熱度

    1回答

    我想創建mockito測試運行休息api下面是控制器類跟隨模擬測試,我試圖執行,但問題是它仍然調用實際的休息API的嘲諷吧, 1)控制器類 public void sendData(ID id, String xmlString, Records record) throws ValidationException{ ClientHttpRequestFactory requestFa

    0熱度

    1回答

    考慮懲戒一個參數的構造函數如下代碼: @Override public void A() { objectA = objectB.B(); objectA.C(someValue); objectC = new constructor(objectA,callback()); //Rest of the code } } public

    0熱度

    1回答

    我有春天接口UserDetailsService的實現: @Service public class UserDetailsServiceImpl implements UserDetailsService { private final UserRepository userRepository; @Autowired public UserDetailsSe

    0熱度

    1回答

    我已經寫了JUnit測試: @Service public class EnterpriseCustomerVerificationService { @Autowired CreditCheckRepository creditCheckRepository; public String FTACheck(StandardInputHeader charterHeaderInputI

    0熱度

    2回答

    我正在測試我的Spring MVC應用程序。 要求是模擬SecurityContext,但我需要Authentication與一些名稱,非空。有沒有辦法做到這一點? 這裏是我的代碼: Authentication auth = Mockito.mock(Authentication.class); SecurityContext secCont = Mockito.mock(SecurityCo

    1熱度

    2回答

    我有數倍BarService相關重載update方法就可以了,就像這樣: BarService#update(Bar bar); BarService#update(Bar bar, boolean checkX); BarService#update(Bar bar, boolean checkX, boolean checkY); 我想,以確保他們的沒有被稱爲在一個特定的測試。目前,我

    0熱度

    1回答

    我正在爲我的Spring MVC控制器編寫測試。 我得到一個org.Mockito.exception.verifications.NoInteractionWanted例外,該堆棧跟蹤: 無相互作用想在這裏: - >在com.test.TestInsertUtente.testInserimentoUtente(TestInsertUtente.java:124) 但發現這種互動: - >在co

    1熱度

    1回答

    我需要測試一個將列表作爲參數的方法。以下是示例代碼: public class C { private int x; private String y; //getters and setters } public class B { public void collectC(List<C> cList) { for(C c :

    1熱度

    2回答

    下面的示例工作正確。問題是我確實需要@InjectMocks註釋。並且,當我用MockitoJUnitRunner.class替換SpringJUnit4ClassRunner.class時,所有內容都會中斷(bar = null而不是testValue)。 如何解決? //@RunWith(MockitoJUnitRunner.class) // not work ( @RunWith(Spri