51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1955|回复: 0
打印 上一主题 下一主题

Appium基础学习之 | UiAutomator与Junit的关系

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-3-11 17:05:39 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
UiAutomator,把代码打包成jar后推送到Android设备上并运行,其中一个重要的步骤就是把一个Bootstrap.jar推送到Android设备,这样结合来说,应该更好的理解Appium与UiAutomator的关系了吧。Bootstrap.jar就如在使用UiAutomator中代码通过ant打包后形成的jar,那么在看看Appium的执行日志,是如何运行Bootstrap.jar的。
如上图,看shell命令,很清楚了,跟在使用UiAutomator中运行是一样的。

接下来再继续看看UiAutomator又是基于什么运行的呢?在使用UiAutomator的时候,需要extends继承UiAutomatorTestCase类,所以来看UiAutomator的UiAutomatorTestCase源码:

  1. package com.android.uiautomator.testrunner;

  2. import android.content.Context;
  3. import android.os.Bundle;
  4. import android.os.RemoteException;
  5. import android.os.ServiceManager;
  6. import android.os.SystemClock;
  7. import android.view.inputmethod.InputMethodInfo;

  8. import com.android.internal.view.IInputMethodManager;
  9. import com.android.uiautomator.core.UiDevice;

  10. import junit.framework.TestCase;

  11. import java.util.List;

  12. /**
  13. * UI automation test should extend this class. This class provides access
  14. * to the following:
  15. * {@link UiDevice} instance
  16. * {@link Bundle} for command line parameters.
  17. * @since API Level 16
  18. */
  19. public class UiAutomatorTestCase extends TestCase {

  20. ...........代码省略

  21. }
复制代码
看上面代码,发现UiAutomatorTestCase实际上是extends继承TestCase,而从import来看,TestCase是属于junit中的类,这里就可以得到结论,所有的执行都是交给Junit来执行的。



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?(注-册)加入51Testing

x
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-9-21 03:30 , Processed in 0.058127 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表