agoda-com / Kakao

This repo is no longer supported. Please visit a https://github.com/KakaoCup/Kakao
Apache License 2.0
1.11k stars 102 forks source link

AssertionFailedError on handling RecyclerView's Item. Problem with 'Expected' and 'Got' #206

Closed Kotlinpin closed 4 years ago

Kotlinpin commented 4 years ago

Hey! Help me please how to figure out next error: I described a recyclerView and its item:

    val foundResultsRecycler: KRecyclerView = KRecyclerView({
        withId(R.id.recycler_row)
    }, itemTypeBuilder = {
        itemType(::FoundItem)
    })
    class FoundItem(parent: Matcher<View>) : KRecyclerItem<FoundItem>(parent) {
        val foundMovie = KTextView(parent) { withId(R.id.media_item) }
    }

i try to check whether item has a text:

SearchScreen{
        foundResultsRecycler.childAt<SearchScreen.FoundItem>(0) {
            foundMovie.hasText(movieTitle)
        }
}

i get an AssertionFailedError:

E/TestRunner: junit.framework.AssertionFailedError: 'with text: is "Joker' doesn't match the selected view.
    Expected: with text: is "Joker"
         Got: "TextView{id=123427859, res-name=media_item, visibility=VISIBLE, width=162, height=49, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, layout-params=android.widget.RelativeLayout$LayoutParams@b6c92a4, tag=null, root-is-layout-requested=false, has-input-connection=false, x=11.0, y=5.0, text=Joker, input-type=0, ime-target=false, has-links=false}"

I do not understand why do i get TextView...

Unlimity commented 4 years ago

Hi! As I see, it matches the item correctly, however I suspect that there are problems with text matching. It might be that there may problems with encoding, or it might be possible that "Joker" is not escaping " symbols in the expected value.

Kotlinpin commented 4 years ago

I see, thank you