zoukankan      html  css  js  c++  java
  • 一起买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());
    
        }
    
    }
    

    测试结果:

    • 发帖模块测试
    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());
    
        }
    
    }
    

    测试结果:

    结果统计

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

    质量评估

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

    测试总结

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

  • 相关阅读:
    GitLab的基础使用-汉化配置
    GitLab的基础使用-数据备份与恢复
    Apache Hadoop集群扩容实战案例
    Hadoop 集群-完全分布式模式(Fully-Distributed Mode)
    HDFS参数调优总结
    网站压力测试 工具webbench
    2013年十大必知的大数据分析公司
    做电子商务网上开店应该读的书
    教你用大功率路由器覆盖3平方公里的WiFi广告
    中央推进城镇化建设 六行业分享25万亿蛋糕
  • 原文地址:https://www.cnblogs.com/wpqwpq/p/6204379.html
Copyright © 2011-2022 走看看