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都有对应的负责人,到时候出错了好找人啊。

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

 

转载于:https://www.cnblogs.com/season-xie/p/6337683.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值