package Ġcom . example . android . architecture . blueprint s . todo app . tasks čĊč Ċ import Ġandroid . os . Bundle č Ċ import Ġandroidx . fragment . app . testing . launch Fragment In Container č Ċ import Ġandroidx . navigation . Nav Controller č Ċ import Ġandroidx . navigation . Navigation č Ċ import Ġandroidx . recyclerview . widget . RecyclerView č Ċ import Ġandroidx . test . espress o . Esp ress o . on View č Ċ import Ġandroidx . test . espress o . action . View Actions . click č Ċ import Ġandroidx . test . espress o . contrib . RecyclerView Actions č Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* č Ċ import Ġandroidx . test . filters . Medium Test č Ċ import Ġandroidx . test . internal . runner . junit 4 . Android JUnit 4 Class Runner č Ċ import Ġcom . example . android . architecture . blueprint s . todo app . R č Ċ import Ġcom . example . android . architecture . blueprint s . todo app . Service Locator č Ċ import Ġcom . example . android . architecture . blueprint s . todo app . data . Task č Ċ import Ġcom . example . android . architecture . blueprint s . todo app . data . source . Fake Android Test Repository č Ċ import Ġcom . example . android . architecture . blueprint s . todo app . data . source . Tasks Repository č Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api č Ċ import Ġkotlinx . coroutines . test . run Blocking Test č Ċ import Ġorg . junit . After č Ċ import Ġorg . junit . Before č Ċ import Ġorg . junit . Test č Ċ import Ġorg . junit . runner . RunWith č Ċ import Ġorg . mockito . Mockito . mock č Ċ import Ġorg . mockito . Mockito . verify čĊč Ċ @ RunWith ( Android JUnit 4 Class Runner :: class ) č Ċ @ Medium Test č Ċ @ Experimental Cor outines Api č Ċ class ĠTasks Fragment Test { čĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġrepository : ĠTasks Repository čĊčĊĠĠĠ Ġ@ Before čĊĠĠĠ Ġfun Ġinit Repository () Ġ{ čĊĠĠĠĠĠĠĠ Ġrepository Ġ= ĠFake Android Test Repository () čĊĠĠĠĠĠĠĠ ĠService Locator . tasks Repository Ġ= Ġrepository čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ Test čĊĠĠĠ Ġfun Ġclick Task _ navigate To Detail Fragment One () Ġ= Ġrun Blocking Test { čĊĠĠĠĠĠĠĠ Ġrepository . save Task ( Task (" TITLE 1 ", Ġ" DESCRIPTION 1 ", Ġfalse , Ġ" id 1 ")) čĊĠĠĠĠĠĠĠ Ġrepository . save Task ( Task (" TITLE 2 ", Ġ" DESCRIPTION 2 ", Ġtrue , Ġ" id 2 ")) čĊčĊĠĠĠĠĠĠĠ Ġval Ġscenario Ġ= Ġlaunch Fragment In Container Ġ< Tasks Fragment >( Bundle (), ĠR . style . App Theme ) čĊčĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġmock ( Nav Controller :: class . java ) čĊčĊĠĠĠĠĠĠĠ Ġscenario . on Fragment Ġ{ čĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . setView Nav Controller ( it . view !! , Ġnav Controller ) čĊĠĠĠĠĠĠĠ Ġ} čĊčĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tasks _ list )) čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform ( RecyclerView Actions . action On Item < RecyclerView . ViewHolder >( čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhas Desc endant ( with Text (" TITLE 1 ")), Ġclick () čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ)) čĊčĊĠĠĠĠĠĠĠ Ġverify ( nav Controller ) čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. navigate ( Tasks Fragment Directions . action Tasks Fragment To Task Detail Fragment (" id 1 ")) čĊĠĠĠ Ġ} čĊčĊĠĠĠ Ġ@ After čĊĠĠĠ Ġfun Ġcleanup Db () Ġ= Ġrun Blocking Test Ġ{ čĊĠĠĠĠĠĠĠ ĠService Locator . reset Repository () čĊĠĠĠ Ġ} č Ċ }