android 功能性测试框架,功能性UI测试

package com.example.administrator.test;

import android.support.test.rule.ActivityTestRule;

import android.support.test.runner.AndroidJUnit4;

import android.test.suitebuilder.annotation.LargeTest;

import com.example.administrator.test.activity.InstrumentActivity;

import org.junit.Rule;

import org.junit.Test;

import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;

import static android.support.test.espresso.action.ViewActions.click;

import static android.support.test.espresso.action.ViewActions.closeSoftKeyboard;

import static android.support.test.espresso.action.ViewActions.typeText;

import static android.support.test.espresso.assertion.ViewAssertions.matches;

import static android.support.test.espresso.matcher.ViewMatchers.withId;

import static android.support.test.espresso.matcher.ViewMatchers.withText;

/**

* @author 林思旭

* @since 2017/11/13

*/

@RunWith(AndroidJUnit4.class)

@LargeTest

public class InstrumentActvityInstrumentationTest{

private static final String content = "magic";

//需要被测试的UI界面对应的Activity(需要测试的目标)

@Rule

public ActivityTestRule mActivityRule = new

ActivityTestRule(InstrumentActivity.class);

@Test

public void sayHello(){

onView(withId(R.id.editText)).perform(typeText("m"));

onView(withId(R.id.editText)).perform(typeText("a"));

onView(withId(R.id.editText)).perform(typeText("g"));

onView(withId(R.id.editText)).perform(typeText("i"));

onView(withId(R.id.editText)).perform(typeText("c"),closeSoftKeyboard());

onView(withText("Say hello!")).perform(click());

String expected = "Hello,"+content+"!";

//检测textView上显示的结果是否和预期想的一样

onView(withId(R.id.textView)).check(matches(withText(expected)));

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值