package Ġid v . ch au yan . do ord ash lite . presentation . screen . restaurant _ list Ċ Ċ import Ġandroidx . fragment . app . testing . launch Fragment In Container Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers . is Displayed Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . filters . Medium Test Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġid v . ch au yan . do ord ash lite . R Ċ import Ġid v . ch au yan . do ord ash lite . mock server . Test WebServer Ċ import Ġid v . ch au yan . do ord ash lite . presentation . screen . restaurant _ list . view . Mock Restaurant List Fragment Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ @ Medium Test Ċ class ĠRest aurant List Fragment Test Ġ{ ĊĊĠ Ġprivate Ġlateinit Ġvar Ġtest WebServer : ĠTest WebServer ĊĊĠ Ġ@ Before ĊĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠ Ġtest WebServer Ġ= ĠTest WebServer () ĊĠĠĠ Ġtest WebServer . onStart () ĊĠ Ġ} ĊĊĠ Ġ@ After ĊĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠ Ġtest WebServer . on Destroy () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġshould Display R eta ur ant List () Ġ{ ĊĊĠĠĠ Ġval Ġscenario Ġ= Ġlaunch Fragment In Container < Mock Restaurant List Fragment >() ĊĠĠĠ Ġscenario . on Fragment Ġ{ ĊĠĠĠĠĠ Ġval Ġrestaurant ListView Ġ= Ġit . activity ?. findViewById < RecyclerView >( R . id . list ) ĊĠĠĠĠĠ Ġval Ġitem Count Ġ= Ġrestaurant ListView ?. adapter ?. item Count ĊĊĠĠĠĠĠ ĠassertThat ( restaurant ListView ). isNotNull () ĊĠĠĠĠĠ ĠassertThat ( item Count ). isNotNull () ĊĠĠĠĠĠ ĠassertThat ( item Count ). isEqualTo ( 1 ) ĊĠĠĠ Ġ} ĊĠĠĠ Ġon View ( with Id ( R . id . list )). check ( matches ( is Displayed ())) ĊĊĊĠ Ġ} Ċ }