一、每次debug都要从头开始听麻烦,据说单元测试可以不用这样了
1、说到单元测试 先从这个开始 https://io2015codelabs.appspot.com/codelabs/android-studio-testing#1
@RunWith(AndroidJUnit4.class)
public class MainActivityInstrumentationTest {
private static final String STRING_TO_BE_TYPED = "Peter";
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<MainActivity>(MainActivity.class);
@Test
public void sayHello() {
onView(ViewMatchers.withId(R.id.editText)).perform(ViewActions.typeText(STRING_TO_BE_TYPED)); //填写字符串
onView(withText("Say hello!")).perform(click()); //点击事件
onView(ViewMatchers.withId(R.id.textView)).check(matches(withText(STRING_TO_BE_TYPED))); //进行对比
}
}