dimanche 3 janvier 2021

Android Testing the Toast in a Fragment Launched by the launchFragmentInContainer Doesn't Work

My test is never running to completion and I have absolutely no idea why. I can see the toast displayed on my phone's screen. There is absolutely nothing in the logs.

@RunWith(AndroidJUnit4::class)
@SmallTest
class BaseDataFragmentUITest
{
    @Test
    fun isDisplayingToastOnlyOnceWhenFAILED_TO_UPDATE()
    {

        var dataState = BaseRepository.DataState.FAILED_TO_UPDATE
        val fragmentScenario = launchFragmentInContainer {
            UITestBaseDataFragmentImp(dataState)
        }
        fragmentScenario.onFragment {
            val toastString: String =  "toast string"

            onView(withText(toastString)).inRoot(withDecorView(not(it.requireActivity().getWindow().getDecorView()))).check(matches(isDisplayed()))
        }

    }
}

Aucun commentaire:

Enregistrer un commentaire