package Ġcom . l az ypot ato . android test practice . ui Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . fragment . app . Fragment Factory Ċ import Ġandroidx . navigation . Nav Controller Ċ import Ġandroidx . navigation . Navigation Ċ 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 . assertThat Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . filters . Medium Test Ċ import Ġcom . google . common . truth . Truth . assertThat Ċ import Ġcom . l az ypot ato . android test practice . R Ċ import Ġcom . l az ypot ato . android test practice . adapters . Image Adapter Ċ import Ġcom . l az ypot ato . android test practice . get Or Await Value Ċ import Ġcom . l az ypot ato . android test practice . launch Fragment In H ilt Container Ċ import Ġcom . l az ypot ato . android test practice . repositories . Fake Shopping Repository Android Test Ċ import Ġdagger . h ilt . android . testing . H ilt Android Rule Ċ import Ġdagger . h ilt . android . testing . H ilt Android Test Ċ import Ġkotlinx . coroutines . Experimental Cor outines Api Ċ import Ġorg . junit . Assert .* Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . mockito . Mockito . mock Ċ import Ġorg . mockito . Mockito . verify Ċ import Ġjavax . inject . Inject ĊĊ Ċ @ H ilt Android Test Ċ @ Medium Test Ċ @ Experimental Cor outines Api Ċ class ĠImage Pick Fragment Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġh ilt Rule Ġ= ĠH ilt Android Rule ( this ) ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġfragment Factory : ĠShop ping Fragment Factory ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġsetup () Ġ{ ĊĠĠĠĠĠĠĠ Ġh ilt Rule . inject () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġclick Image _ pop Back Stack AndSet ImageUrl () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġnav Controller Ġ= Ġmock ( Nav Controller :: class . java ) ĊĊĠĠĠĠĠĠĠ Ġval ĠimageUrl Ġ= Ġ" TEST " ĊĊĠĠĠĠĠĠĠ Ġval Ġtest ViewModel Ġ= ĠShop ping ViewModel ( Fake Shopping Repository Android Test ()) ĊĊĠĠĠĠĠĠĠ Ġlaunch Fragment In H ilt Container < Image Pick Fragment >( fragment Factory Ġ= Ġfragment Factory ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . setView Nav Controller ( require View (), Ġnav Controller ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġimage Adapter . images Ġ= ĠlistOf ( imageUrl ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel Ġ= Ġtest ViewModel ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . rv Images )). perform ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠRecyclerView Actions . action On Item At Position < Image Adapter . ImageView Holder >( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ 0 , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġclick () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġverify ( nav Controller ). pop Back Stack () ĊĠĠĠĠĠĠĠ ĠassertThat ( test ViewModel . cur ImageUrl . get Or Await Value ()). isEqualTo ( imageUrl ) ĊĠĠĠ Ġ} Ċ }