package Ġat . mark i . d agger ino Ċ Ċ import Ġandroidx . test . espress o . Esp ress o . on View Ċ import Ġandroidx . test . espress o . action . View Actions .* Ċ import Ġandroidx . test . espress o . assertion . View Assertions . matches Ċ import Ġandroidx . test . espress o . matcher . View Matchers .* Ċ import Ġandroidx . test . ext . junit . runners . Android JUnit 4 Ċ import Ġandroidx . test . rule . Activity Test Rule Ċ import Ġat . mark i . d agger ino . views . main . MainActivity Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ import Ġorg . junit . runner . RunWith Ċ Ċ @ RunWith ( Android JUnit 4 :: class ) Ċ class ĠMainActivity Test Ġ{ ĊĊĠĠĠ Ġ@ get : Rule ĊĠĠĠ Ġvar Ġactivity Rule : ĠActivity Test Rule < MainActivity > Ġ= ĠActivity Test Rule ( ĊĠĠĠĠĠĠĠ ĠMainActivity :: class . java ĊĠĠĠ Ġ) ĊĊĠĠĠ Ġ@ Test ĊĠĠĠ Ġfun Ġtype AN umber _ result Is Displayed () Ġ{ ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . et _ factor ial )). perform ( type Text (" 1 "), Ġclose Soft Keyboard ()) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . btn _ compute )). perform ( click ()) ĊĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tv _ result )). check ( matches ( is Displayed ())) ĊĠĠĠĠĠĠĠ Ġon View ( with Id ( R . id . tv _ result )). check ( matches ( with Text (" 1 "))) ĊĠĠĠ Ġ} Ċ } Ċ