日記
カシスリキュールをコーラで割ると美味しいらしいので今日やる。
コード
fun navigate_to_words_nav_component() { val navController = TestNavHostController( ApplicationProvider.getApplicationContext() ) val letterListScenario = launchFragmentInContainer<LetterListFragment>( themeResId = R.style.Theme_Words ) letterListScenario.onFragment { fragment -> navController.setGraph(R.navigation.nav_graph) Navigation.setViewNavController(fragment.requireView(), navController) } onView(withId(R.id.recycler_view)) .perform( RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>( 2, click() ) ) assertEquals(navController.currentDestination?.id, R.id.wordListFragment) }
感想
UI要素は変化させずにNavigation Controllerが期待通りのdestinationにたどり着いたかをテストしているらしい。ほーんという感想しかなくて本当に何も理解していないことがわかったので写経以外のこともやる。やります…