package Ġorg . fn ives . test . show case . ui . login Ċ Ċ import Ġandroidx . arch . core . executor . testing . Instant Task Executor Rule Ċ import Ġandroidx . lifecycle . Lifecycle Ċ import Ġandroidx . test . core . app . Activity Scenario Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġorg . fn ives . test . show case . R Ċ import Ġorg . fn ives . test . show case . network . mock server . scenario . auth . Auth Scenario Ċ import Ġorg . fn ives . test . show case . test utils . Mock Server Scenario Setup Test Rule Ċ import Ġorg . fn ives . test . show case . test utils . Reload K oin Modules If Ne cessary Test Rule Ċ import Ġorg . fn ives . test . show case . test utils . configuration . Specific Test Configurations Factory Ċ import Ġorg . fn ives . test . show case . test utils . id ling . Disposable Ċ import Ġorg . fn ives . test . show case . test utils . id ling . Network Synchronization Ċ import Ġorg . fn ives . test . show case . test utils . robot . Robot Test Rule Ċ import Ġorg . fn ives . test . show case . ui . auth . Auth Activity Ċ import Ġorg . junit . After Ċ import Ġorg . junit . Before Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ import Ġorg . k oin . test . K oin Test Ċ Ċ @ Suppress (" Test FunctionName ") Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠAuth Activity Test Ġ: ĠK oin Test Ġ{ ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġactivity Scenario : ĠActivity Scenario < Auth Activity > ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġinstant Task Executor Rule Ġ= ĠInstant Task Executor Rule () ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġsn ackbar Verification Test Rule Ġ= ĠSpecific Test Configurations Factory . create Snackbar Verification () ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġrobot Rule Ġ= ĠRobot Test Rule ( Login Robot ()) ĊĠĠĠ Ġprivate Ġval Ġlogin Robot Ġget () Ġ= Ġrobot Rule . robot ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġmock Server Scenario Setup Test Rule Ġ= ĠMock Server Scenario Setup Test Rule () ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġmain Dispatcher Test Rule Ġ= ĠSpecific Test Configurations Factory . create Main Dispatcher Test Rule () ĊĊĠĠĠ Ġ@ Rule ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġval Ġreload K oin Modules If Ne cessary Test Rule Ġ= ĠRe load K oin Modules If Ne cessary Test Rule () ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġdis posable : ĠDis posable ĊĊĠĠĠ Ġ@ Before ĊĠĠĠ Ġfun ĠsetUp () Ġ{ ĊĠĠĠĠĠĠĠ ĠSpecific Test Configurations Factory . create Server Type Configuration () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. invoke ( mock Server Scenario Setup Test Rule . mock Server Scenario Setup ) ĊĠĠĠĠĠĠĠ Ġdis posable Ġ= ĠNetwork Synchronization . register Networking Synchronization () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ After ĊĠĠĠ Ġfun ĠtearDown () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity Scenario . moveTo State ( Lifecycle . State . DESTROY ED ) ĊĠĠĠĠĠĠĠ Ġdis posable . dispose () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠG IV EN Ġnon Ġempty Ġpassword Ġand Ġusername Ġand Ġsuccessful Ġresponse ĠWHEN Ġsign In ĠTHEN Ġno Ġerror Ġis Ġshown Ġand Ġnavig ating Ġto Ġhome Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġproper Login Results In Navigation To Home () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Server Scenario Setup Test Rule . mock Server Scenario Setup . set Scenario ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAuth Scenario . Success ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġpassword Ġ= Ġ" al ma ", ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġusername Ġ= Ġ" ban an " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( Auth Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġlogin Robot ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Password (" al ma ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Username (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Password (" al ma ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Username (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. click On Login () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Loading Before Requests () ĊĊĠĠĠĠĠĠĠ Ġmain Dispatcher Test Rule . advance Until Idle Or Activity Is Destroyed () ĊĠĠĠĠĠĠĠ Ġlogin Robot . assert Navig ated To Home () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠG IV EN Ġempty Ġpassword Ġand Ġusername ĠWHEN Ġsign In ĠTHEN Ġerror Ġpassword Ġis Ġshown Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġempty Password Shows Pro per ErrorMessage () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( Auth Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġlogin Robot ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Username (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Username (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. click On Login () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Loading Before Requests () ĊĊĠĠĠĠĠĠĠ Ġmain Dispatcher Test Rule . advance Until Idle With Id ling Resources () ĊĠĠĠĠĠĠĠ Ġlogin Robot . assert Error Is Shown ( R . string . password _ is _ invalid ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Navig ated To Home () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Loading () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠG IV EN Ġpassword Ġand Ġempty Ġusername ĠWHEN Ġsign In ĠTHEN Ġerror Ġusername Ġis Ġshown Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġempty UserName Shows Pro per ErrorMessage () Ġ{ ĊĠĠĠĠĠĠĠ Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( Auth Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġlogin Robot ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Password (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Password (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. click On Login () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Loading Before Requests () ĊĊĠĠĠĠĠĠĠ Ġmain Dispatcher Test Rule . advance Until Idle With Id ling Resources () ĊĠĠĠĠĠĠĠ Ġlogin Robot . assert Error Is Shown ( R . string . username _ is _ invalid ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Navig ated To Home () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Loading () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠG IV EN Ġpassword Ġand Ġusername Ġand Ġinvalid Ġcredentials Ġresponse ĠWHEN Ġsign In ĠTHEN Ġerror Ġinvalid Ġcredentials Ġis Ġshown Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġinvalid Credentials Given Shows Pro per ErrorMessage () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Server Scenario Setup Test Rule . mock Server Scenario Setup . set Scenario ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAuth Scenario . Invalid Credentials ( username Ġ= Ġ" al ma ", Ġpassword Ġ= Ġ" ban an ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( Auth Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġlogin Robot ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Username (" al ma ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Password (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Username (" al ma ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Password (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. click On Login () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Loading Before Requests () ĊĊĠĠĠĠĠĠĠ Ġmain Dispatcher Test Rule . advance Until Idle With Id ling Resources () ĊĠĠĠĠĠĠĠ Ġlogin Robot . assert Error Is Shown ( R . string . credentials _ invalid ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Navig ated To Home () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Loading () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/** ĠG IV EN Ġpassword Ġand Ġusername Ġand Ġerror Ġresponse ĠWHEN Ġsign In ĠTHEN Ġerror Ġinvalid Ġcredentials Ġis Ġshown Ġ*/ ĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġnetwork Error Shows Pro per ErrorMessage () Ġ{ ĊĠĠĠĠĠĠĠ Ġmock Server Scenario Setup Test Rule . mock Server Scenario Setup . set Scenario ( ĊĠĠĠĠĠĠĠĠĠĠĠ ĠAuth Scenario . Generic Error ( username Ġ= Ġ" al ma ", Ġpassword Ġ= Ġ" ban an ") ĊĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġactivity Scenario Ġ= ĠActivity Scenario . launch ( Auth Activity :: class . java ) ĊĠĠĠĠĠĠĠ Ġlogin Robot ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Username (" al ma ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Password (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Username (" al ma ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Password (" ban an ") ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. click On Login () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assert Loading Before Requests () ĊĊĠĠĠĠĠĠĠ Ġmain Dispatcher Test Rule . advance Until Idle With Id ling Resources () ĊĠĠĠĠĠĠĠ Ġlogin Robot . assert Error Is Shown ( R . string . something _ w ent _ wrong ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Navig ated To Home () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. assertNot Loading () ĊĠĠĠ Ġ} Ċ } Ċ