Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
断言错误:断言失败-Android JUnit Mockito_Android_Unit Testing_Kotlin_Mockito - Fatal编程技术网

断言错误:断言失败-Android JUnit Mockito

断言错误:断言失败-Android JUnit Mockito,android,unit-testing,kotlin,mockito,Android,Unit Testing,Kotlin,Mockito,我不能断言由于某种原因而失败的语句,尽管我已经嘲笑了这些要求。我找不出原因 任何帮助都将不胜感激。您似乎会将一个字符串与某个事件进行比较,这相当于苹果和梨 它可能是相似的: @Before fun setUp() { val compositeDisposable = CompositeDisposable() testScheduler = TestScheduler() val testSchedulerProvider = TestSchedulerProvide

我不能断言由于某种原因而失败的语句,尽管我已经嘲笑了这些要求。我找不出原因


任何帮助都将不胜感激。

您似乎会将一个
字符串
与某个
事件
进行比较,这相当于苹果和梨

它可能是相似的:

 @Before
fun setUp() {
    val compositeDisposable = CompositeDisposable()
    testScheduler = TestScheduler()
    val testSchedulerProvider = TestSchedulerProvider(testScheduler)
    sharedViewModel = SharedViewModel(
        testSchedulerProvider,
        compositeDisposable,
        networkHelper,
        repository, notesRepository, userPreferences
    )
    sharedViewModel.noteSaving.observeForever(
        noteSavingObserver
    )
    sharedViewModel.clearNoteText.observeForever(clearNoteTextObserver)

}


@Test
fun givenServerResponse200_whenNotesSaved_shouldclearTextField() {
    val notes = "testNote"
    val latitude = 3.62176
    val longitude = -7.932457
    sharedViewModel.notesField.value = notes
    sharedViewModel.latLongField.value =
        LocationModel(latitude, longitude)
    sharedViewModel.currentLocation.value = "test location"
    val newNote = Notes(latitude, longitude, notes, userPreferences.getUserId())
    doReturn(true)
        .`when`(networkHelper)
        .isNetworkConnected()

    doReturn(Single.just(true))
        .`when`(notesRepository).addNotes(newNote)
    assert(sharedViewModel.clearNoteText.value == Event("Note Saved Successfully"))

    sharedViewModel.addNote()
    testScheduler.triggerActions()
}
或:


请发布您的SharedViewModel类。
sharedViewModel.clearNoteText.value.equals("Note Saved Successfully")
sharedViewModel.clearNoteText.value == "Note Saved Successfully"