zoukankan      html  css  js  c++  java
  • Robotium怎样判断测试结果

    Robotium判断测试结果的方法主要有三类:assert、is、search。assert方法除了Robotium API,还有Junit中的所有断言方法,Junit的断言方法下篇详解。

     

    void assertCurrentActivity (String message, Class activityClass [,boolean isNewInstance])
    断言当前的activity是否是预期的
    参数:
    message-如果运行失败打印的消息
    activityClass-预期的activity
    isNewInstance-可选项,实际activity是否是预期activity的继承,如果为true则只要是继承关系就通过,false则必须是当前activity
    返回:无
     
    void assertCurrentActivity (String message, String name [,boolean isNewInstance])
    断言当前的activity是否是预期的
    参数:
    message-如果运行失败打印的消息
    name-预期activity的名字
    isNewInstance-可选项,实际activity是否是预期activity的继承,如果为true则只要是继承关系就通过,false则必须是当前activity
    返回:无
     
    注:以上两个断言方法,一般在知道activity的情况下使用。如果拿不到activity,会用得比较少,比如没有源码的情况下,只知道启动activity,其他activity名称获取比较费劲,只好通过其他途径校验测试结果。
     
    void assertMemoryNotLow()

    断言目前系统可用内存是否过低,内存空间足够则通过

    返回:无

    is方法

    boolean isCheckBoxChecked (int index | String text)

    判断checkBox是否处于被选中的状态,可以通过index和text两种方法定位

    参数:

    index-检查的checkBox的索引值,如果只有一个可用则为0

    text-检查的checkBox的文字,可使用正则表达式

    返回:

    true-如果被选中

    false-如果没有被选中 

    boolean isRadioButtonChecked (int index | String text)

    判断RadioButton是否处于被选中的状态,可以通过index和text两种方法定位

    参数:

    index-检查的RadioButton的索引值,如果只有一个可用则为0

    text-检查的RadioButton的文字,可使用正则表达式

    返回:

    true-如果被选中

    false-如果没有被选中 

    boolean isRadioButtonChecked (int index | String text)

    判断RadioButton是否处于被选中的状态,可以通过index和text两种方法定位

    参数:

    index-检查的RadioButton的索引值,如果只有一个可用则为0

    text-检查的RadioButton的文字,可使用正则表达式

    返回:

    true-如果被选中

    false-如果没有被选中 

    boolean isToggleButtonChecked (int index | String text)

    判断ToggleButton是否处于被选中的状态,可以通过index和text两种方法定位

    参数:

    index-检查的ToggleButton的索引值,如果只有一个可用则为0

    text-检查的ToggleButton的文字,可使用正则表达式

    返回:

    true-如果被选中

    false-如果没有被选中


    boolean isSpinnerTextSelected ( [int index, ]  String text)

    判断SpinnerText是否处于被选中的状态,可以通过index定位

    参数:

    index-检查的SpinnerText的索引值,如果只有一个可用则为0

    text-检查的SpinnerText的文字,可使用正则表达式 

    返回:

    true-如果被选中

    false-如果没有被选中

    boolean isTextChecked (String text)

    判断text是否处于被选中的状态,可以通过text定位

    参数:

    text-检查的text的文字,可使用正则表达式

    返回:

    true-如果被选中

    false-如果没有被选中

     

    search方法

    boolean searchButton (String text [, int minimumNumberOfMatches, boolean onlyVisible])

    判断当前的屏幕中是否能找到指定的button

    参数:

    text-查找的button的文字

    minimumNumberOfMatches-最小指定多少才算是通过,0表示1个或者多个

    onlyVisible-只记录可见的

    返回:

    true-如果找到了该控件

    false-如果没有找到该控件

     

    boolean searchText (String text [, int minimumNumberOfMatches, boolean scroll, boolean onlyVisible])

    判断当前的屏幕中是否能找到指定的text,即文本

    参数: 

    text-查找的Text的文字

    minimumNumberOfMatches-最小指定多少才算是通过,0表示1个或者多个

    scroll-是否允许滚动搜索,true表示支持,false表示只能在当前屏幕内查找

    onlyVisible-只记录可见的

    返回:

    true-如果找到了该文本

    false-如果没有找到该文本 

    boolean searchToggleButton (String text [, int minimumNumberOfMatches])

    判断当前的屏幕中是否能找到指定的ToggleButton

    参数:

    text-查找的ToggleButton的文字

    minimumNumberOfMatches-最小指定多少才算是通过,0表示1个或者多个

    返回:

    true-如果找到了该控件

    false-如果没有找到该控件 

    boolean searchEditText (String text)

    判断当前的屏幕中是否能找到指定的EditText

    参数:

    text-查找的Text的文字

    返回:

    true-如果找到了该文本

    false-如果没有找到该文本

  • 相关阅读:
    Linux进程关系
    ambari 卸载脚本
    CentOS-7.2安装Ambari-2.6.1
    MYSQL57密码策略修改
    CentOS7 离线安装MySQL
    centos 安装mysql Package: akonadi-mysql-1.9.2-4.el7.x86_64 (@anaconda)
    mysql 数据备份
    spring-boot-starter-thymeleaf对没有结束符的HTML5标签解析出错
    ssh: scp命令
    python:os.path
  • 原文地址:https://www.cnblogs.com/lucy-lily/p/4991299.html
Copyright © 2011-2022 走看看