Last active
June 18, 2019 02:39
-
-
Save fo2rist/e1e2780bc25d0a31ccb1dcecc0da031b to your computer and use it in GitHub Desktop.
Simple Espresso Test Setup / Basic Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(AndroidJUnit4::class) | |
class BaseMainActivityTest { | |
@get:Rule | |
var activityRule = ActivityTestRule(MainActivity::class.java) | |
// the context is often needed in more complex Espresso tests | |
protected val context: Context by lazy { activityRule.activity } | |
@Test | |
fun greeterSaysHello() { | |
onView(withId(R.id.name_field)).perform(typeText("Steve")) | |
onView(withId(R.id.greet_button)).perform(click()) | |
onView(withText("Hello Steve!")).check(matches(isDisplayed())) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment