zoukankan      html  css  js  c++  java
  • uiautomator 自定义注解的应用

    自定义注解tester

    @Target({java.lang.annotation.ElementType.METHOD})
    @Retention(RetentionPolicy.RUNTIME)
    public @interface Tester {
        public abstract String value() default "无名氏";
    }

    在testcase中引用

    @Tester("zhangsan")
        public void test004() throws IOException, AutoException,
                UiObjectNotFoundException, NotRootException, RemoteException {

    在结果统计中应用

    public String getTester(){
             Tester tester = (Tester)getTestCaseAnnotation(Tester.class);
              return ((tester != null) ? tester.value() : "");        
        }
        
          private <T extends Annotation> T getTestCaseAnnotation(Class<T> clazz) {
                try {
                  if (getClass().isAnnotationPresent(clazz))
                    return getClass().getAnnotation(clazz);
    
                  Method method = getClass().getMethod(getName(), new Class[0]);
                  if (method.isAnnotationPresent(clazz))
                    return method.getAnnotation(clazz);
                }
                catch (NoSuchMethodException e)
                {
                }
                return null;
              }

    总结:为每个case都指定了tester,就是每个case都有对应的负责人,到时候出错了好找人啊。

    其实还有很多其他的应用,大家可以想下

  • 相关阅读:
    HashMap 和HashTable
    两种方式获得键盘录入
    打印流 printStream
    对象操作流--存储对象
    内存输出流
    序列流
    装饰设计模式
    递归
    IO流(使用指定的码表读写字符)
    IO-字符流 练习
  • 原文地址:https://www.cnblogs.com/season-xie/p/6337683.html
Copyright © 2011-2022 走看看