-
Notifications
You must be signed in to change notification settings - Fork 9
Get Started
To get started you can also look at this example project.
Add test dependency
androidTestCompile ('de.nenick:espresso-macchiato:0.5.0')
Explicit espresso dependency is not necessary.
Add additional test dependency when your need permission handling
androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
Its recommend to extend the EspPage but not necessary. It would give you some standard actions and checks you can do with a page.
The EspPage constructor requests a resource id. Optimal this should be unique and is only used once for a specific layout. This avoid that you must select view hierarchies, or strange test effects like report visible but should not exist anymore.
public class MyPage extends EspPage {
public MyPage() {
super(R.id.layout_activity_first_page);
}
}
With this page you can start writing your tests by checking that this page is currently shown assertIsVisible
or not assertNotExist
.
For each element use a simple access method in your Page Object.
public EspButton myButton() {
return EspButton.byId(R.id.my_button)
}
public EspTextView myTextView() {
return EspTextView.byId(R.id.my_text_view)
}