package com.cky.learnandroiddetails;

import android.os.SystemClock;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.cky.learnandroiddetails.UnitTestExample.TestUnitTestAct;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**
 * 作者：cky
 * 时间：2016/9/28 15:18
 * 描述：
 */
@RunWith(AndroidJUnit4.class)
public class MyActivityTest {

    @Rule
    public ActivityTestRule<TestUnitTestAct> mActivityTestRule = new ActivityTestRule<>(TestUnitTestAct.class);

    @Test
    public void testGreat() {

        onView(withId(R.id.edit_text)).perform(typeText("Tim"), closeSoftKeyboard());

        SystemClock.sleep (5000);

        onView(withText("Hello")).perform(click());

        SystemClock.sleep (5000);

        onView(withId(R.id.text_view)).equals("Hello, Tim");

        SystemClock.sleep (5000);

    }
}

@@ -778,16 +778,94 @@
 ithText;
+%0Aimport static android.support.test.espresso.assertion.ViewAssertions.matches;
 %0A%0A/**%0A *
@@ -1383,14 +1383,30 @@
 w)).
-equals
+check(matches(withText
 (%22He
@@ -1415,16 +1415,18 @@
 o, Tim%22)
+))
 ;%0A%0A     

更新 【Android Test】