To achieve what you want you need two things:
To set a date to a datepicker the best way is to make use of the espresso PickerActions, I wrote about them here and here, but will copy some parts of my answer from there:
The easiest way is to to make use of the PickerActions.setDate
method:
onView(withId(R.id.start_date_picker)).perform(PickerActions.setDate(2017, 6, 30));
To get this working, you have to add the com.android.support.test.espresso:espresso-contrib
library in your gradle file and maybe exclude some libraries, please check my linked answers above if you have trouble with that.
For the second part, to check the date of a DatePicker I think you have to use a custom matcher.
You could add this method to your code:
public static Matcher<View> matchesDate(final int year, final int month, final int day) {
return new BoundedMatcher<View, DatePicker>(DatePicker.class) {
@Override
public void describeTo(Description description) {
description.appendText("matches date:");
}
@Override
protected boolean matchesSafely(DatePicker item) {
return (year == item.getYear() && month == item.getMonth() && day == item.getDayOfMonth());
}
};
}
Which you then can use to check a date like this:
onView(withId(R.id.end_date_picker)).check(matches(matchesDate(2017, 6, 30)));