mockito

    0熱度

    2回答

    我有一個java類 - 非常典型的通常的單身 - 像這樣: 請注意:爲簡潔起見,我在這裏省略了「if null」邏輯,因爲那不是我我遇到了麻煩,而且我不想擠出問題。 public class MySingleton { ObjectMapper mapper; private MySingleton() { new MySingleton(new Ob

    -1熱度

    1回答

    因此,這裏的情景 public class Report { public void Generate { if (!isValidDate) { return; } //calling other method } protected boolean isValidDate() { boolean i

    -1熱度

    1回答

    我試圖測試中使用的Android中的Mockito改造科特林的API客戶端類,它看起來像這樣: class SomeApiClient : SomeApi { private val service: SomeApiService constructor(service: SomeApiService) { this.service = service

    1熱度

    1回答

    我有mockito方法的問題:when(...)。當我測試: afterThrowExceptionShouldReturnCorrectHttpStatus() 然先,那麼第二個測試: controllerShouldReturnListOfAnns() ,因爲它扔NotFoundException它總是失敗。當我第一次刪除第一個測試或第二次測試時,那麼一切都是正確的。這看起來像方法when()

    1熱度

    1回答

    這個問題以前已經問過,但現有的答案並不完全適用於我的情況。 我想測試submitCode()方法: public class VerificationCodeViewModel{ //Input public final ObservableField<String> verificationCode = new ObservableField<>(); //

    -1熱度

    2回答

    的Mockito模擬Java函數我有一個類,像這樣: @Component public class AddressConverter { public Function<Address, AddressDTO> convertToDTO = new Function<Address, AddressDTO>() { public AddressDTO app

    0熱度

    1回答

    我是新來mockito測試,我一直在試圖跟隨博客,但它現在非常混亂。 座右銘是測試FileUtility類中的兩個靜態函數。代碼如下。 public static boolean isExternalStorageWritable() { String state = Environment.getExternalStorageState(); if (Environment.

    0熱度

    1回答

    的Mockito 我對我的一些靜態字段的使用@Getter符號與龍目島這樣嘲諷龍目島田@Getter的代碼,不會: MyClass.getMyClass(); 嘲笑,我這樣做: mock(MyClass.class); when(MyClass.getMyClass()).thenReturn(...); Howeve r,這樣的模擬給出了下面的錯誤。 [testng] org.mock

    1熱度

    1回答

    我有一個像下面的測試類。需要模擬內部HmUtils.class一個靜態方法, @RunWith(PowerMockRunner.class) @PrepareForTest({Environment.class, HmUtils.class}) public class MyUtilTest { @Mock Context mockedContext; @Before public v

    0熱度

    2回答

    我在SpringBoot中的RestController上編寫集成測試。 通常我會用SpringRunner.class運行,但是當涉及到模擬靜態方法時,我需要使用PowerMock。 奇怪的事實是,當我運行一個測試,它們分別通過(但返回錯誤消息),當我嘗試運行整個測試類,沒有測試通過並返回相同的錯誤消息。 @RunWith(PowerMockRunner.class) @PrepareForT