檢測設備測試

public class InstrumentationTest
extends Object implements IAbiReceiver, IConfigurationReceiver, IDeviceTest, IMetricCollectorReceiver, IRemoteTest, ITestCollector

java.lang.Object
   ↳ com.android.tradefed.testtype.InstrumentationTest


在指定裝置上執行檢測設備測試套件的測試。

摘要

欄位

public static final String RUN_TESTS_AS_USER_KEY

public static final String RUN_TESTS_ON_SDK_SANDBOX

protected boolean mDebug

protected boolean mInstrumentSdkInSandbox

protected boolean mInstrumentSdkSandbox

公用建構函式

InstrumentationTest()

公用方法

void addDeviceListeners( extraListeners)

允許新增更多自訂事件監聽器至執行器

void addInstrumentationArg(String key, String value)

新增執行檢測設備測試時提供的引數。

IAbi getAbi()
IConfiguration getConfiguration()

取得這項測試的 IConfiguration

String getCoverageTarget()

取得先前透過 setCoverageTarget(String) 設定的涵蓋率 Target。

boolean getDebug()

取得檢測偵錯設定。

ITestDevice getDevice()

取得要測試的裝置。

String getForceAbi()
long getMaxTimeout()

傳回檢測作業設定的逾時時間上限。

String getPackageName()

取得要執行的 Android 資訊清單套件。

String getRunName()

取得要提供給事件監聽器的自訂測試執行作業名稱

String getRunnerName()

取得要使用的 Android 檢測執行器。

boolean isOrchestrator()

傳回 ERROR(InstrumentationTest#mOrchestrator/com.android.tradefed.testtype.InstrumentationTest#mOrchestrator InstrumentationTest#mOrchestrator) 的值

void run(TestInformation testInfo, ITestInvocationListener listener)

執行測試,並將結果回報給事件監聽器。

void setAbi(IAbi abi)
void setClassName(String testClassName)

您也可以設定要執行的測試類別名稱。

void setCollectTestsOnly(boolean shouldCollectTest)

啟用或停用測試收集模式

void setCollectsTestsShellTimeout(int timeout)

此方法已淘汰。 這是一項免人工管理

void setConfiguration(IConfiguration config)

插入使用中的 IConfiguration

void setCoverageTarget(String coverageTarget)

設定這項測試的涵蓋範圍目標。

void setDebug(boolean debug)

調整檢測偵錯設定。

void setDevice(ITestDevice device)

插入要測試的裝置。

void setEnforceFormat(boolean enforce)

如果我們強制執行 AJUR 輸出格式,請設定 True。

void setForceAbi(String abi)

設定 force-abi 選項。

void setInstallFile(File installFile)

設定要安裝包含測試的選用檔案。

void setIsolatedStorage(boolean isolatedStorage)

設定我們是否使用獨立儲存空間。

void setMethodName(String testMethodName)

您也可以設定要執行的測試方法。

void setMetricCollectors( collectors)

設定測試執行作業定義的 IMetricCollector 清單。

void setOrchestrator(boolean useOrchestrator)

設定 --orchestrator 選項

void setPackageName(String packageName)

設定要執行的 Android 資訊清單套件。

void setReRunUsingTestFile(boolean reRunUsingTestFile)

設定 --rerun-from-file 選項。

void setRerunMode(boolean rerun)

您可以視需要設定重新執行模式。

void setRunName(String runName)

設定要提供給事件監聽器的自訂測試執行作業名稱

void setRunnerName(String runnerName)

您也可以設定要使用的 Android 檢測執行器。

void setShellTimeout(long timeout)

您可以視需要設定裝置預期殼層輸出的時間上限 (以毫秒為單位)。

void setTestFilePathOnDevice(String testFilePathOnDevice)

視需要設定裝置上應含有行清單的檔案路徑 要執行的測試類別和方法 (格式:com.foo.Class#method)。

void setTestPackageName(String testPackageName)

設定測試套件篩選器。

void setTestSize(String size)

您也可以設定要執行的測試大小。

void setTestTimeout(long timeout)

您可以視需要設定每次測試執行作業的時間上限 (以毫秒為單位)。

void setTestsToRun( tests)

設定此 InstrumentationTest 應執行的測試集合。

void setWindowAnimation(boolean windowAnimation)

保護方法

static excludeNonExecuted(TestRunResult results)

濾除「NOT_EXECUTED」已略過,以便追蹤需要重新執行的項目。

String getClassName()

取得要執行的類別名稱。

ListInstrumentationParser getListInstrumentationParser()

取得用來剖析「pm list instrumentation」的 ListInstrumentationParser舉個簡單的例子,您可以定義情境 並指示 AI 如何回應服務中心查詢

String getMethodName()

取得要執行的測試方法。

String getTestPackageName()

取得要執行的 Java 套件。

String queryRunnerName()

查詢裝置要使用的測試執行器。

void setRunnerArgs(IRemoteAndroidTestRunner runner)

欄位

RUN_TESTS_AS_USER_KEY

public static final String RUN_TESTS_AS_USER_KEY

RUN_TESTS_ON_SDK_SANDBOX

public static final String RUN_TESTS_ON_SDK_SANDBOX

mDebug

protected boolean mDebug

mInstrumentSdkInSandbox

protected boolean mInstrumentSdkInSandbox

mInstrumentSdkSandbox

protected boolean mInstrumentSdkSandbox

公用建構函式

檢測設備測試

public InstrumentationTest ()

公用方法

addDeviceListeners

public void addDeviceListeners ( extraListeners)

允許新增更多自訂事件監聽器至執行器

參數
extraListeners

addInstrumentationArg

public void addInstrumentationArg (String key, 
                String value)

新增執行檢測設備測試時提供的引數。

參數
key String:引數名稱

value String:引數值

getAbi

public IAbi getAbi ()

傳回
IAbi

getConfiguration

public IConfiguration getConfiguration ()

取得這項測試的 IConfiguration

傳回
IConfiguration

getCoverageTarget

public String getCoverageTarget ()

取得先前透過 setCoverageTarget(String) 設定的涵蓋率 Target。

傳回
String

取得偵錯

public boolean getDebug ()

取得檢測偵錯設定。

傳回
boolean 布林值偵錯設定。

getDevice

public ITestDevice getDevice ()

取得要測試的裝置。

傳回
ITestDevice ITestDevice

getForceAbi

public String getForceAbi ()

傳回
String

getMaxTimeout

public long getMaxTimeout ()

傳回檢測作業設定的逾時時間上限。

傳回
long

getPackageName

public String getPackageName ()

取得要執行的 Android 資訊清單套件。

傳回
String

getRunName

public String getRunName ()

取得要提供給事件監聽器的自訂測試執行作業名稱

傳回
String

getRunnerName

public String getRunnerName ()

取得要使用的 Android 檢測執行器。

傳回
String

得分

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

執行測試,並將結果回報給事件監聽器。

參數
testInfo TestInformationTestInformation 物件,包含可執行的實用資訊 測試。

listener ITestInvocationListener:測試結果的 ITestInvocationListener

擲回
DeviceNotAvailableException

SetAbi

public void setAbi (IAbi abi)

參數
abi IAbi

setClassName

public void setClassName (String testClassName)

您也可以設定要執行的測試類別名稱。

參數
testClassName String

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

啟用或停用測試收集模式

setCollectsTestsShellTimeout

public void setCollectsTestsShellTimeout (int timeout)

此方法已淘汰。
這個方法屬於免人工管理

設定「殼層輸出回應長度上限」(毫秒) 的時間上限 (毫秒)收集相關資訊 測試。

參數
timeout int

setConfiguration

public void setConfiguration (IConfiguration config)

插入使用中的 IConfiguration

參數
config IConfiguration

設定涵蓋率目標

public void setCoverageTarget (String coverageTarget)

設定這項測試的涵蓋範圍目標。

目前未使用。此方法只是存在,以便稍後可透過 getCoverageTarget()

參數
coverageTarget String

setDebug

public void setDebug (boolean debug)

調整檢測偵錯設定。

參數
debug boolean:用於檢測偵錯設定的布林值。

setDevice

public void setDevice (ITestDevice device)

插入要測試的裝置。

參數
device ITestDevice:要使用的 ITestDevice

setEnforceFormat

public void setEnforceFormat (boolean enforce)

如果我們強制執行 AJUR 輸出格式,請設定 True。

參數
enforce boolean

setForceAbi

public void setForceAbi (String abi)

設定 force-abi 選項。

setInstallFile

public void setInstallFile (File installFile)

設定要安裝包含測試的選用檔案。

參數
installFile File:可安裝的 ERROR(/File)

setIsolatedStorage

public void setIsolatedStorage (boolean isolatedStorage)

設定我們是否使用獨立儲存空間。

參數
isolatedStorage boolean

setMethodName

public void setMethodName (String testMethodName)

您也可以設定要執行的測試方法。

參數
testMethodName String

setMetricCollectors

public void setMetricCollectors ( collectors)

設定測試執行作業定義的 IMetricCollector 清單。

參數
collectors

setOrchestrator

public void setOrchestrator (boolean useOrchestrator)

設定 --orchestrator 選項

參數
useOrchestrator boolean

setPackageName

public void setPackageName (String packageName)

設定要執行的 Android 資訊清單套件。

參數
packageName String

setReRunUsingTestFile

public void setReRunUsingTestFile (boolean reRunUsingTestFile)

設定 --rerun-from-file 選項。

參數
reRunUsingTestFile boolean

setRerunMode

public void setRerunMode (boolean rerun)

您可以視需要設定重新執行模式。

參數
rerun boolean

setRunName

public void setRunName (String runName)

設定要提供給事件監聽器的自訂測試執行作業名稱

參數
runName String

setRunnerName

public void setRunnerName (String runnerName)

您也可以設定要使用的 Android 檢測執行器。

參數
runnerName String

setShellTimeout

public void setShellTimeout (long timeout)

您可以視需要設定裝置預期殼層輸出的時間上限 (以毫秒為單位)。

參數
timeout long

setTestFilePathOnDevice

public void setTestFilePathOnDevice (String testFilePathOnDevice)

視需要設定裝置上應含有行清單的檔案路徑 要執行的測試類別和方法 (格式:com.foo.Class#method)。如果已設定, 透過 InstrumentationFileTest 自動嘗試以這個測試檔案重新執行測試,而不是針對每項其餘測試分別執行 ADB 指令 重新執行

參數
testFilePathOnDevice String

setTestPackageName

public void setTestPackageName (String testPackageName)

設定測試套件篩選器。

如果是非空值,則只會在指定 Java 套件中執行測試。

如果為 setClassName(String) 提供非空值,將會忽略這個欄位

參數
testPackageName String

setTestSize

public void setTestSize (String size)

您也可以設定要執行的測試大小。

參數
size String

setTestTimeout

public void setTestTimeout (long timeout)

您可以視需要設定每次測試執行作業的時間上限 (以毫秒為單位)。

參數
timeout long

setTestsToRun

public void setTestsToRun ( tests)

設定此 InstrumentationTest 應執行的測試集合。

參數
tests :要執行的測試

setWindowAnimation

public void setWindowAnimation (boolean windowAnimation)

參數
windowAnimation boolean

保護方法

排除未執行

protected static  excludeNonExecuted (TestRunResult results)

濾除「NOT_EXECUTED」已略過,以便追蹤需要重新執行的項目。

參數
results TestRunResult

傳回

getClassName

protected String getClassName ()

取得要執行的類別名稱。

傳回
String

getListInstrumentationParser

protected ListInstrumentationParser getListInstrumentationParser ()

取得用來剖析「pm list instrumentation」的 ListInstrumentationParser舉個簡單的例子,您可以定義情境 並指示 AI 如何回應服務中心查詢

傳回
ListInstrumentationParser

getMethodName

protected String getMethodName ()

取得要執行的測試方法。

傳回
String

getTestPackageName

protected String getTestPackageName ()

取得要執行的 Java 套件。

傳回
String

queryRunnerName

protected String queryRunnerName ()

查詢裝置要使用的測試執行器。

傳回
String 與套件相符的第一個測試執行器名稱,如果找不到,則傳回空值。

擲回
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

參數
runner IRemoteAndroidTestRunner