package Ġio . sell ma ir . k omp ass . android . test . fragment Ċ Ċ import Ġandroid . widget . TextView Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . test . espress o . Esp ress o Ċ import Ġio . sell ma ir . k omp ass . android . test . Fragment Host Activity Ċ import Ġio . sell ma ir . k omp ass . android . test . flat View Hierarchy Ċ import Ġorg . junit . Assert ĊĊ Ċ inline Ġfun Ġ< re ified ĠT Ġ: ĠFragment > ĠFragment Host Activity . assert Shows Fragment () Ġ{ ĊĠĠĠ ĠE sp ress o . on Idle () ĊĠĠĠ Ġval Ġfragment TextView Ġ= ĠfindViewById < TextView ? >( R . id . fragment Text ) ĊĠĠĠ ĠcheckNotNull ( fragment TextView ) Ġ{ Ġ" Required Ġfragment Ġ${ T :: class . java . simple Name }, Ġbut Ġno Ġfragment Ġis Ġpresent " Ġ} ĊĠĠĠ ĠAssert . assertEquals (" Wrong Ġfragment Ġdisplayed .", ĠT :: class . text (), Ġfragment TextView . text ) ĊĊĠĠĠ Ġval Ġfragment Text Count Ġ= Ġfragment TextView . root View . flat View Hierarchy (). count Ġ{ Ġview Ġ-> Ġview . id Ġ== ĠR . id . fragment Text Ġ} ĊĠĠĠ ĠAssert . assertEquals (" More Ġthan Ġone Ġfragment Ġis Ġcurrently Ġdisplayed ", Ġ 1 , Ġfragment Text Count ) Ċ } ĊĊĊ