儀表測試

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

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

公共構造函數

InstrumentationTest ()

公共方法

void addDeviceListeners ( extraListeners) addDeviceListeners ( extraListeners)

允許向跑步者添加更多自定義偵聽器

void addInstrumentationArg (String key, String value)

在運行檢測測試時添加要提供的參數。

IAbi getAbi ()
IConfiguration getConfiguration ()

獲取此測試的IConfiguration

String getCoverageTarget ()

獲取之前通過setCoverageTarget(String)設置的 coverageTarget。

boolean getDebug ()

獲取儀器調試設置。

ITestDevice getDevice ()

獲取被測設備。

String getForceAbi ()
long getMaxTimeout ()

返回為檢測設置的最大超時。

String getPackageName ()

獲取要運行的 Android 清單包。

String getRunName ()

獲取將提供給偵聽器的自定義測試運行名稱

String getRunnerName ()

獲取要使用的 Android 檢測運行器。

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) setMetricCollectors ( collectors)

設置為測試運行定義的IMetricCollector列表。

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)

(可選)設置期望從設備輸出 shell 的最長時間(以毫秒為單位)。

void setTestFilePathOnDevice (String testFilePathOnDevice)

或者,將路徑設置為位於設備上的文件,該文件應包含要運行的行分隔的測試類和方法的列表(格式:com.foo.Class#method)。

void setTestPackageName (String testPackageName)

設置測試包過濾器。

void setTestSize (String size)

(可選)將測試大小設置為運行。

void setTestTimeout (long timeout)

或者,為每個單獨的測試運行設置最長時間(以毫秒為單位)。

void setTestsToRun ( tests) setTestsToRun ( tests)

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

void setWindowAnimation (boolean windowAnimation)

受保護的方法

static excludeNonExecuted ( TestRunResult results)

為了跟踪需要重新運行的內容,過濾掉“NOT_EXECUTED”。

String getClassName ()

獲取要運行的類名。

ListInstrumentationParser getListInstrumentationParser ()

獲取用於解析“pm list instrumentation”查詢的ListInstrumentationParser

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

公共構造函數

儀表測試

public InstrumentationTest ()

公共方法

addDeviceListeners

public void addDeviceListeners ( extraListeners)

允許向跑步者添加更多自定義偵聽器

參數
extraListeners

addInstrumentationArg

public void addInstrumentationArg (String key, 
                String value)

在運行檢測測試時添加要提供的參數。

參數
key String :參數名稱

value String : 參數值

得到阿比

public IAbi getAbi ()

退貨
IAbi

獲取配置

public IConfiguration getConfiguration ()

獲取此測試的IConfiguration

退貨
IConfiguration

獲取覆蓋目標

public String getCoverageTarget ()

獲取之前通過setCoverageTarget(String)設置的 coverageTarget。

退貨
String

獲取調試

public boolean getDebug ()

獲取儀器調試設置。

退貨
boolean布爾調試設置。

獲取設備

public ITestDevice getDevice ()

獲取被測設備。

退貨
ITestDevice ITestDevice

getForceAbi

public String getForceAbi ()

退貨
String

getMaxTimeout

public long getMaxTimeout ()

返回為檢測設置的最大超時。

退貨
long

獲取包裹名稱

public String getPackageName ()

獲取要運行的 Android 清單包。

退貨
String

獲取運行名稱

public String getRunName ()

獲取將提供給偵聽器的自定義測試運行名稱

退貨
String

獲取跑步者姓名

public String getRunnerName ()

獲取要使用的 Android 檢測運行器。

退貨
String

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

運行測試,並將結果報告給監聽器。

參數
testInfo TestInformationTestInformation對象包含運行測試的有用信息。

listener ITestInvocationListener : 測試結果的ITestInvocationListener

投擲
DeviceNotAvailableException

設置阿比

public void setAbi (IAbi abi)

參數
abi IAbi

設置類名

public void setClassName (String testClassName)

(可選)將測試類名稱設置為運行。

參數
testClassName String

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

啟用或禁用測試收集模式

setCollectsTestsShellTimeout

public void setCollectsTestsShellTimeout (int timeout)

此方法已棄用。
此方法是無操作的

以毫秒為單位設置最大時間,以在收集測試時允許“shell 輸出響應的最大時間”。

參數
timeout int

設置配置

public void setConfiguration (IConfiguration config)

注入正在使用的IConfiguration

參數
config IConfiguration

設置覆蓋目標

public void setCoverageTarget (String coverageTarget)

設置本次測試的覆蓋目標。

目前未使用。此方法僅存在,因此稍後可以通過getCoverageTarget()檢索 coverageTarget

參數
coverageTarget String

設置調試

public void setDebug (boolean debug)

設置儀器調試設置。

參數
debug boolean : 設置檢測調試設置的布爾值。

設置設備

public void setDevice (ITestDevice device)

注入被測設備。

參數
device ITestDevice :要使用的ITestDevice

設置強制格式

public void setEnforceFormat (boolean enforce)

如果我們強制執行檢測的 AJUR 輸出格式,則設置為 True。

參數
enforce boolean

setForceAbi

public void setForceAbi (String abi)

設置 force-abi 選項。

設置安裝文件

public void setInstallFile (File installFile)

設置要安裝的包含測試的可選文件。

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

設置隔離存儲

public void setIsolatedStorage (boolean isolatedStorage)

設置是否使用隔離存儲。

參數
isolatedStorage boolean

設置方法名

public void setMethodName (String testMethodName)

(可選)將測試方法設置為運行。

參數
testMethodName String

setMetricCollectors

public void setMetricCollectors ( collectors)

設置為測試運行定義的IMetricCollector列表。

參數
collectors

設置包名

public void setPackageName (String packageName)

將 Android 清單包設置為運行。

參數
packageName String

setReRunUsingTestFile

public void setReRunUsingTestFile (boolean reRunUsingTestFile)

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

參數
reRunUsingTestFile boolean

設置重新運行模式

public void setRerunMode (boolean rerun)

(可選)設置重新運行模式。

參數
rerun boolean

設置運行名稱

public void setRunName (String runName)

設置將提供給偵聽器的自定義測試運行名稱

參數
runName String

setRunnerName

public void setRunnerName (String runnerName)

(可選)設置要使用的 Android 檢測運行器。

參數
runnerName String

設置ShellTimeout

public void setShellTimeout (long timeout)

(可選)設置期望從設備輸出 shell 的最長時間(以毫秒為單位)。

參數
timeout long

setTestFilePathOnDevice

public void setTestFilePathOnDevice (String testFilePathOnDevice)

或者,將路徑設置為位於設備上的文件,該文件應包含要運行的行分隔的測試類和方法的列表(格式:com.foo.Class#method)。如果設置,將自動嘗試通過InstrumentationFileTest使用此測試文件重新運行測試,而不是通過重新運行為每個剩餘的測試執行單獨的 adb 命令。

參數
testFilePathOnDevice String

設置測試包名稱

public void setTestPackageName (String testPackageName)

設置測試包過濾器。

如果非空,則僅執行給定 java 包中的測試。

如果已為setClassName(String)提供了非空值,則將被忽略

參數
testPackageName String

設置測試大小

public void setTestSize (String size)

(可選)將測試大小設置為運行。

參數
size String

設置測試超時

public void setTestTimeout (long timeout)

或者,為每個單獨的測試運行設置最長時間(以毫秒為單位)。

參數
timeout long

setTestsToRun

public void setTestsToRun ( tests)

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

參數
tests :要運行的測試

設置窗口動畫

public void setWindowAnimation (boolean windowAnimation)

參數
windowAnimation boolean

受保護的方法

excludeNonExecuted

protected static  excludeNonExecuted (TestRunResult results)

為了跟踪需要重新運行的內容,過濾掉“NOT_EXECUTED”。

參數
results TestRunResult

退貨

獲取類名

protected String getClassName ()

獲取要運行的類名。

退貨
String

getListInstrumentationParser

protected ListInstrumentationParser getListInstrumentationParser ()

獲取用於解析“pm list instrumentation”查詢的ListInstrumentationParser

退貨
ListInstrumentationParser

獲取方法名

protected String getMethodName ()

獲取要運行的測試方法。

退貨
String

獲取測試包名稱

protected String getTestPackageName ()

獲取要運行的測試 java 包。

退貨
String

queryRunnerName

protected String queryRunnerName ()

查詢設備以供測試運行程序使用。

退貨
String第一個與包匹配的測試運行器名稱,如果找不到,則返回 null。

投擲
DeviceNotAvailableException

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

參數
runner IRemoteAndroidTestRunner