zoukankan      html  css  js  c++  java
  • 旅图——UI测试

    测试目标

    • 保证代码质量,确保基础功能的实现,可以有效地保证代码的可靠性,让模块在与别的模块整合时出现更少的错误,减少最终测试时查找困难无方向。

    UI测试

    登录过程

    • 模拟登录过程,密码正确与密码错误的情况

    测试代码

    package com.example.asdf.test;
    import android.support.test.rule.ActivityTestRule;
    import android.support.test.runner.AndroidJUnit4;
    import android.test.suitebuilder.annotation.LargeTest;
    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.matcher.ViewMatchers.withId;
    @RunWith(AndroidJUnit4.class)
    @LargeTest
    public class loginTest {
    @Rule
    public ActivityTestRule<login> mActivityRule = new ActivityTestRule<>(
            login.class);
    @Test
    public void sayHello(){
        onView(withId(R.id.account)).perform(typeText("1234567890"), closeSoftKeyboard());
        onView(withId(R.id.password)).perform(typeText("1234567890"),closeSoftKeyboard());
        onView(withId(R.id.login)).perform(click());
    }
    } 
    

    测试结果

    密码错误

    密码正确

    用户信息修改

    • 模拟用户信息修改过程,修改成功

    测试代码

    public class modifyInformation {
    
    
    @Rule
    public ActivityTestRule<modifyinformation> mActivityRule = new ActivityTestRule<>(
            modifyinformation.class);
    
    @Test
    public void modify(){
        onView(withId(R.id.newusername)).perform(typeText("fire"), closeSoftKeyboard());
        onView(withId(R.id.newintroduce)).perform(typeText("233"),closeSoftKeyboard());
        onView(withId(R.id.newsubmit)).perform(click());
    }
    }
    

    测试结果

    测试总结

    • 测试通过。由于app含有涉及到从服务器获取图片信息的功能模块与获取验证码功能,无法通过espresso进行UI自动化测试,只能进行登录过程测试展示。
  • 相关阅读:
    LeetCode 205. Isomorphic Strings
    LeetCode 191. Number of 1 Bits
    InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_1' with dtype float and shape [?,10]
    tensorflow环境下安装scikit-learn
    LeetCode 136. Single Number
    LeetCode 70. Climbing Stairs
    TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'
    Window系统 安装TFLearn
    在tensorflow环境下安装matplotlib
    mysql三元运算,上下连表,视图,触发器,存储过程,事务等不常用方法
  • 原文地址:https://www.cnblogs.com/606notconnected/p/6212869.html
Copyright © 2011-2022 走看看