package Ġpl . gd g . my application Ċ Ċ import Ġandroidx . test . core . app . launch Activity Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions . click Ċ import Ġandroidx . test . espress o . assertion . View Assertions Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Id Ċ import Ġandroidx . test . espress o . matcher . View Matchers . with Text Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . platform . app . Instrumentation Registry Ċ import Ġorg . junit . Assert . assertEquals Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ /** Ċ Ġ* ĠInstrument ed Ġtest , Ġwhich Ġwill Ġexecute Ġon Ġan ĠAndroid Ġdevice . Ċ Ġ* Ċ Ġ* ĠSee Ġ[ testing Ġdocumentation ]( http :// d . android . com / tools / testing ). Ċ Ġ*/ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠExample Instrument ed Test Ġ{ ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġuse AppContext () Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠContext Ġof Ġthe Ġapp Ġunder Ġtest . ĊĠĠĠĠĠĠĠ Ġval Ġapp Context Ġ= ĠInstrument ation Registry . get Instrumentation (). target Context ĊĠĠĠĠĠĠĠ ĠassertEquals (" pl . gd g . workshop 1 6 ", Ġapp Context . packageName ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġchanges Label After Go Click () Ġ{ ĊĠĠĠĠĠĠĠ Ġlaunch Activity < MainActivity >(). use Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label )). check ( View Assertions . matches ( with Text (" Hello ĠWorld ! "))) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Text (" Go ! ")). perform ( click ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . label )). check ( View Assertions . matches ( with Text (" Go ing ! "))) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }