package Ġcom . github . ny times news app . screens . main Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġcom . github . ny times news app . base . Base UT Test Ċ import Ġcom . github . ny times news app . di . configure Test App Component Ċ import Ġcom . github . ny times news app . main . data . source . News Remote Data Ċ import Ġcom . github . ny times news app . main . domain . News UseCase Ċ import Ġcom . github . ny times news app . main . domain . Params Ċ import Ġkotlinx . coroutines . run Blocking Ċ import Ġorg . junit . Assert . assertNotNull Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . junit . runners . JUnit 4 Ċ import Ġorg . k oin . core . context . start K oin Ċ import Ġorg . k oin . test . get Ċ import Ġjava . net . Http URLConnection Ċ Ċ @ RunWith ( JUnit 4 :: class ) Ċ class ĠNews UseCase Test Ġ: ĠBase UT Test () Ġ{ ĊĊĠĠĠ Ġ// Target ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm News UseCase : ĠNews UseCase ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġnews Remote Data : ĠNews Remote Data ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġinstant Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġval Ġm Param Ġ= ĠParams (" 1 ") ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun Ġstart () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . setUp () ĊĠĠĠĠĠĠĠ Ġ// Start ĠK oin Ġwith Ġrequired Ġdependencies ĊĠĠĠĠĠĠĠ Ġstart K oin Ġ{ Ġmodules ( configure Test App Component ( getMock WebServer Url ())) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtest _ login _ use _ case _ returns _ expected _ value () Ġ= Ġrun Blocking Ġ{ ĊĊĠĠĠĠĠĠĠ Ġnews Remote Data Ġ= Ġget () ĊĠĠĠĠĠĠĠ Ġmock Network Response With FileContent (" test . json ", ĠHttp URLConnection . HTTP _ OK ) ĊĠĠĠĠĠĠĠ Ġm News UseCase Ġ= ĠNews UseCase ( news Remote Data ) ĊĊĠĠĠĠĠĠĠ Ġval Ġdata Received Ġ= Ġm News UseCase . run ( m Param ) ĊĊĠĠĠĠĠĠĠ ĠassertNotNull ( data Received ) ĊĠĠĠĠĠĠĠ Ġassert ( data Received . isNotEmpty ()) ĊĠĠĠ Ġ} Ċ Ċ }