悠悠小仙仙 发表于 2019-3-11 17:05:39

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

UiAutomator,把代码打包成jar后推送到Android设备上并运行,其中一个重要的步骤就是把一个Bootstrap.jar推送到Android设备,这样结合来说,应该更好的理解Appium与UiAutomator的关系了吧。Bootstrap.jar就如在使用UiAutomator中代码通过ant打包后形成的jar,那么在看看Appium的执行日志,是如何运行Bootstrap.jar的。
如上图,看shell命令,很清楚了,跟在使用UiAutomator中运行是一样的。

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

package com.android.uiautomator.testrunner;

import android.content.Context;
import android.os.Bundle;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.view.inputmethod.InputMethodInfo;

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

import junit.framework.TestCase;

import java.util.List;

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

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

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



页: [1]
查看完整版本: Appium基础学习之 | UiAutomator与Junit的关系