SORU
1 Mart 2013, Cuma


Geçersiz bir yöntem bir istisna atar Mockito test

void dönüş türü olan bir yöntem var. Ayrıca bu istisnalar atılan test etmek istediğim çok özel bir sayı atabilir. Tüm girişimler aynı nedenle başarısız oldu:

Yazın Stubber(T) yöntemi bağımsız değişkenler (geçersiz) için geçerli değildir

Bu yöntem, belirli bir özel durum için nasıl alabilirim herhangi bir fikir?

doThrow(new Exception()).when(mockedObject.methodReturningVoid(...));

CEVAP
1 Mart 2013, Cuma


Kullanmanız gerekir

doThrow(new Exception()).when(mockedObject).methodReturningVoid(...);

değil

doThrow(new Exception()).when(mockedObject.methodReturningVoid(...));

Bu the documentation olarak açıklanmıştır

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Disney Pets and Animals

    Disney Pets

    29 ŞUBAT 2012
  • TheOtherMau5

    TheOtherMau5

    6 Mart 2012
  • TotalxLuna

    TotalxLuna

    27 Kasım 2011