package Ġcom . openj its u . android . openj its u Ċ Ċ import Ġandroid . view . View Ċ import Ġandroidx . recyclerview . widget . RecyclerView Ċ import Ġandroidx . test . espress o . No Matching View Exception Ċ import Ġandroidx . test . espress o . View Assertion Ċ import Ġandroidx . test . espress o . matcher . View Matchers . assertThat Ċ import Ġjunit . framework . Assert . assertTrue Ċ import Ġorg . hamcrest . Matcher Ċ import Ġorg . hamcrest . Matchers .` is ` Ċ Ċ /* Ċ Ġ* Ġhttps :// stackoverflow . com / a / 3 9 4 4 6 8 8 9 Ċ Ġ* Ċ Ġ* ĠUsage : Ċ Ġ* Ċ Ġ* Ġon View ( with Id ( R . id . re cyclerView )). check ( new ĠRecyclerView ItemCount Assertion ( 5 )); Ċ Ġ* Ġon View ( with Id ( R . id . re cyclerView )). check ( new ĠRecyclerView ItemCount Assertion ( greater Than ( 5 )); Ċ Ġ* Ġon View ( with Id ( R . id . re cyclerView )). check ( new ĠRecyclerView ItemCount Assertion ( less Than ( 5 )); Ċ Ġ*/ Ċ class ĠRecyclerView ItemCount Assertion Ġprivate Ġconstructor ( private Ġval Ġmatcher : ĠMatcher < Int >) Ġ: ĠView Assertion Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġcheck ( view : ĠView , Ġno View Found Exception : ĠNo Matching View Exception ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( no View Found Exception Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow Ġno View Found Exception ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġval Ġre cyclerView Ġ= Ġview Ġas ĠRecyclerView ĊĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= Ġre cyclerView . adapter ĊĠĠĠĠĠĠĠ ĠassertThat ( adapter !!. item Count , Ġmatcher ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĊĠĠĠĠĠĠĠ Ġfun Ġwith ItemCount ( expected Count : ĠInt ): ĠRecyclerView ItemCount Assertion Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġwith ItemCount (` is `( expected Count )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġfun Ġwith ItemCount ( matcher : ĠMatcher < Int >): ĠRecyclerView ItemCount Assertion Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠRecyclerView ItemCount Assertion ( matcher ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }