【发布时间】:2017-03-22 15:17:10
【问题描述】:
我在 Espresso 中编写测试来测试 MyFragment。好的。
需要在 MyFragment 中调用自定义方法 customUpdate() 的写入测试方法:
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, true, false);
@Before
public void init() {
mActivityRule.launchActivity(intent);
// Here forward to MyFragment
onView(withId(R.id.myTextView)).perform(click());
}
@Test
public void searchAddFavorite() {
// update column in db
MyService.updateColumn(context, 123, Profile.MY_COLUMN_NAME, false);
// here need to call fragment custom method customUpdate()
onView(withId(R.id.searchView)).perform(click());
}
片段(MyFragment)中的自定义方法更改光标。
private void customUpdate() {
cursor = MyService.getCursor(context, someFilter, true);
contactAdapter.changeCursor(cursor);
}
我该怎么做?
【问题讨论】: