一起买beta版UI测试

一起买beta版UI测试

测试目的

保证代码质量,对各个单元进行测试,可以有效地保证代码的可靠性,让模块在与别的模块整合时出现更少的错误。

UI测试

  • 登录模块测试

​ 登录模拟过程。

  • 发帖模块测试

​ 发帖模拟过程

测试过程

  • 登录模块测试
package com.example.s.buytogether;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;

import com.example.s.buytogether.login.Login;

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.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class LoginTest {

    private static final String STRING_TO_BE_TYPED = "b";

    @Rule
    public ActivityTestRule<Login> mActivityRule = new ActivityTestRule<>(
            Login.class);

    @Test
    public void login() {
        onView(withId(R.id.edtTxt_userName)).perform(typeText("b"));
        onView(withId(R.id.edtTxt_userPassword)).perform(typeText("b"));
        onView(withId(R.id.btn_login)).perform(click());

    }

}

测试结果:

990007-20161220212910182-1008423830.gif

  • 发帖模块测试
package com.example.s.buytogether;

import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.test.suitebuilder.annotation.LargeTest;

import com.example.s.buytogether.newPosts.NewPosts;

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.scrollTo;
import static android.support.test.espresso.action.ViewActions.typeText;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class NewPostsTest {


    @Rule
    public ActivityTestRule<NewPosts> mActivityRule = new ActivityTestRule<>(
            NewPosts.class);

    @Test
    public void login() {
        onView(withId(R.id.edtTxt_description)).perform(scrollTo(), typeText("yaobuyaolaiwana~~~"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_location)).perform(scrollTo(), typeText("30#417"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_phone)).perform(scrollTo(), typeText("110"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_indateTimeDay)).perform(scrollTo(), typeText("30"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_indateTimeHour)).perform(scrollTo(), typeText("2"), closeSoftKeyboard());
//        onView(withId(R.id.edtTxt_moreDescription)).perform(scrollTo(), typeText("hahahahhaha"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_price)).perform(scrollTo(), typeText("30"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_unit)).perform(scrollTo(), typeText("po"), closeSoftKeyboard());
        onView(withId(R.id.edtTxt_menCount)).perform(scrollTo(), typeText("2"), closeSoftKeyboard());
//        onView(withId(R.id.img_addPosts)).perform(click());

    }

}

测试结果:

990007-20161220212922479-1382506715.gif

结果统计

共计两个测试,两个均无问题

质量评估

所测试模块,均可正常通过

测试总结

由于时间原因,只做了两个部分的UI测试,其他部分依然还是存在一系列的bug正在解决中。但是也感觉espresso这个UI自动化测试的厉害之处,避免了人工手动的复杂输入,操作起来很炫酷。

转载于:https://www.cnblogs.com/wpqwpq/p/6204379.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值