-
Notifications
You must be signed in to change notification settings - Fork 0
Annotations in espresso
Devrath edited this page May 17, 2021
·
10 revisions
Title |
---|
AndroidJUnit4ClassRunner |
ActivityTestRule |
@RunWith(AndroidJUnit4ClassRunner::class)
class MainActivityTest {
@Test
fun greet() {
}
}
AndroidJUnit4ClassRunner::class
--> This specifies the tests written in this class is an android test
@RunWith(AndroidJUnit4ClassRunner::class)
class MainActivityTest {
@Rule @JvmField
var activityRule = ActivityTestRule<MainActivity>(MainActivity::class.java)
@Test
fun greet() { }
}
- ActivityTestRule is used to tell espresso which activity to run before running the tests in the test class.
- By this rule the
activity
is run every time before each test. -
@JvmField
, this is required to make the@Rule
work.