BaseHostJUnit4Test
public abstract class BaseHostJUnit4Test
extends Object
implements IAbiReceiver , ITestInformationReceiver
java.lang.Object |
↳ | com.android.tradefed.testtype.junit4.BaseHostJUnit4Test |
用於運行主機 JUnit4 樣式測試的基礎測試類。此類提供從主機端安裝、運行和清理儀器測試的支持。這個類是多設備兼容的。應該是從主機端運行儀器測試的唯一真實來源,以避免重複的實用程序和基類。
概括
公共方法 |
---|
final void | autoTearDown () 自動拆除所有已安裝的 apk。 |
final IAbi | getAbi () |
final IBuildInfo | getBuild () |
final ITestDevice | getDevice () |
final IInvocationContext | getInvocationContext () |
final TestRunResult | getLastDeviceRunResults () 返回由運行的最新 runDeviceTests 產生的TestRunResult 。 |
final | getListDevices () |
TestInformation | getTestInformation () |
boolean | hasDeviceFeature (String feature) |
final void | installPackage ( DeviceTestRunOptions options) 在設備上安裝基於DeviceTestRunOptions 的 apk。 |
final void | installPackage (String apkFileName, String... options) 在設備上安裝一個給定名稱的 apk。 |
final void | installPackage ( ITestDevice device, String apkFileName, String... options) 在給定設備上安裝給定名稱的 apk。 |
final void | installPackageAsUser ( ITestDevice device, String apkFileName, boolean grantPermission, int userId, String... options) 在給定設備上為特定用戶安裝一個給定名稱的 apk。 |
final void | installPackageAsUser (String apkFileName, boolean grantPermission, int userId, String... options) 為特定用戶安裝一個給定名稱的 apk。 |
final boolean | isPackageInstalled (String pkg) 檢查設備上是否安裝了給定名稱的包 |
final boolean | isPackageInstalled ( ITestDevice device, String pkg) 檢查設備上是否安裝了給定名稱的包 |
final boolean | runDeviceTests ( ITestDevice device, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( ITestDevice device, String pkgName, String testClassName, String testMethodName, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, boolean isWindowAnimationDisabled, instrumentationArgs, extraListeners) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, boolean isWindowAnimationDisabled, instrumentationArgs, extraListeners) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, boolean isWindowAnimationDisabled, instrumentationArgs, extraListeners) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( ITestDevice device, String pkgName, String testClassName, String testMethodName, Long testTimeoutMs) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, instrumentationArgs) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, instrumentationArgs) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests (String pkgName, String testClassName, String testMethodName) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( DeviceTestRunOptions options) 根據DeviceTestRunOptions 中的信息運行檢測。 |
final boolean | runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, boolean isWindowAnimationDisabled, boolean isRestartDisabled, instrumentationArgs, extraListeners) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, boolean isWindowAnimationDisabled, boolean isRestartDisabled, instrumentationArgs, extraListeners) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, boolean isWindowAnimationDisabled, boolean isRestartDisabled, instrumentationArgs, extraListeners) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( ITestDevice device, String pkgName, String testClassName, String testMethodName) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests (String pkgName, String testClassName, Integer userId, Long testTimeoutMs) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests (String pkgName, String testClassName) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests (String pkgName, String testClassName, Long testTimeoutMs) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, instrumentationArgs, extraListeners) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, instrumentationArgs, extraListeners) runDeviceTests ( ITestDevice device, String runner, String pkgName, String testClassName, String testMethodName, Integer userId, Long testTimeoutMs, Long maxTimeToOutputMs, Long maxInstrumentationTimeoutMs, boolean checkResults, boolean isHiddenApiCheckDisabled, boolean isTestApiCheckDisabled, boolean isIsolatedStorageDisabled, instrumentationArgs, extraListeners) 運行已安裝的檢測包的方法。 |
final boolean | runDeviceTests (String runner, String pkgName, String testClassName, String testMethodName) 運行已安裝的檢測包的方法。 |
final void | setAbi ( IAbi abi) |
final void | setTestInformation ( TestInformation testInformation) |
final String | uninstallPackage (String pkgName) 卸載設備上的軟件包。 |
final String | uninstallPackage ( ITestDevice device, String pkgName) 卸載設備上的包 |
公共構造函數
BaseHostJUnit4Test
public BaseHostJUnit4Test ()
公共方法
自動拆卸
public final void autoTearDown ()
自動拆除所有已安裝的 apk。這將從安裝它們的設備上卸載所有 apk。
得到阿比
public final IAbi getAbi ()
獲取列表設備
public final getListDevices ()
hasDeviceFeature
public boolean hasDeviceFeature (String feature)
安裝包
public final void installPackage (String apkFileName,
String... options)
在設備上安裝一個給定名稱的 apk。 Apk 將被自動清理。
參數 |
---|
apkFileName | String :apk 文件的名稱。 |
options | String :提供給安裝命令的額外選項 |
安裝包
public final void installPackage (ITestDevice device,
String apkFileName,
String... options)
在給定設備上安裝給定名稱的 apk。 Apk 將被自動清理。
參數 |
---|
device | ITestDevice :要在其上安裝 apk 的ITestDevice 。 |
apkFileName | String :apk 文件的名稱。 |
options | String :提供給安裝命令的額外選項 |
installPackageAsUser
public final void installPackageAsUser (ITestDevice device,
String apkFileName,
boolean grantPermission,
int userId,
String... options)
在給定設備上為特定用戶安裝一個給定名稱的 apk。
參數 |
---|
device | ITestDevice :要在其上安裝 apk 的ITestDevice 。 |
apkFileName | String :apk 文件的名稱。 |
grantPermission | boolean : 安裝apk時是否傳遞grant permission flag。 |
userId | int :安裝 apk 的用戶的用戶 ID。 |
options | String :提供給安裝命令的額外選項 |
installPackageAsUser
public final void installPackageAsUser (String apkFileName,
boolean grantPermission,
int userId,
String... options)
為特定用戶安裝一個給定名稱的 apk。
參數 |
---|
apkFileName | String :apk 文件的名稱。 |
grantPermission | boolean : 安裝apk時是否傳遞grant permission flag。 |
userId | int :安裝 apk 的用戶的用戶 ID。 |
options | String :提供給安裝命令的額外選項 |
isPackageInstalled
public final boolean isPackageInstalled (String pkg)
檢查設備上是否安裝了給定名稱的包
isPackageInstalled
public final boolean isPackageInstalled (ITestDevice device,
String pkg)
檢查設備上是否安裝了給定名稱的包
參數 |
---|
device | ITestDevice :應該卸載包的設備。 |
pkg | String :包的名稱 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String pkgName,
String testClassName,
String testMethodName,
Integer userId,
Long testTimeoutMs)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
userId | Integer :要針對其運行測試的用戶的 ID。可以為空。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String pkgName,
String testClassName,
String testMethodName,
Long testTimeoutMs,
Long maxTimeToOutputMs,
Long maxInstrumentationTimeoutMs)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
maxTimeToOutputMs | Long :測試必須開始輸出內容的最大超時。 |
maxInstrumentationTimeoutMs | Long :完整檢測必須完成的最大超時。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String runner,
String pkgName,
String testClassName,
String testMethodName,
Integer userId,
Long testTimeoutMs,
Long maxTimeToOutputMs,
Long maxInstrumentationTimeoutMs,
boolean checkResults,
boolean isHiddenApiCheckDisabled,
boolean isTestApiCheckDisabled,
boolean isIsolatedStorageDisabled,
boolean isWindowAnimationDisabled,
instrumentationArgs,
extraListeners)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
runner | String |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
userId | Integer :要針對其運行測試的用戶的 ID。可以為空。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
maxTimeToOutputMs | Long :測試必須開始輸出內容的最大超時。 |
maxInstrumentationTimeoutMs | Long :完整檢測必須完成的最大超時。 |
checkResults | boolean :是否檢查結果是否有崩潰。 |
isHiddenApiCheckDisabled | boolean :我們是否應該禁用隱藏的 api 檢查。 |
isTestApiCheckDisabled | boolean :我們是否應該禁用測試 api 檢查。 |
isIsolatedStorageDisabled | boolean :我們是否應該禁用隔離存儲。 |
isWindowAnimationDisabled | boolean :我們是否應該禁用窗口動畫。 |
instrumentationArgs | : 傳遞給檢測的參數。 |
extraListeners | |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String pkgName,
String testClassName,
String testMethodName,
Long testTimeoutMs)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String runner,
String pkgName,
String testClassName,
String testMethodName,
Integer userId,
Long testTimeoutMs,
Long maxTimeToOutputMs,
Long maxInstrumentationTimeoutMs,
boolean checkResults,
boolean isHiddenApiCheckDisabled,
instrumentationArgs)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
runner | String |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
userId | Integer :要針對其運行測試的用戶的 ID。可以為空。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
maxTimeToOutputMs | Long :測試必須開始輸出內容的最大超時。 |
maxInstrumentationTimeoutMs | Long :完整檢測必須完成的最大超時。 |
checkResults | boolean :是否檢查結果是否有崩潰。 |
isHiddenApiCheckDisabled | boolean :我們是否應該禁用隱藏的 api 檢查。 |
instrumentationArgs | : 傳遞給檢測的參數。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (String pkgName,
String testClassName,
String testMethodName)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String runner,
String pkgName,
String testClassName,
String testMethodName,
Integer userId,
Long testTimeoutMs,
Long maxTimeToOutputMs,
Long maxInstrumentationTimeoutMs,
boolean checkResults,
boolean isHiddenApiCheckDisabled,
boolean isTestApiCheckDisabled,
boolean isIsolatedStorageDisabled,
boolean isWindowAnimationDisabled,
boolean isRestartDisabled,
instrumentationArgs,
extraListeners)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
runner | String |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
userId | Integer :要針對其運行測試的用戶的 ID。可以為空。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
maxTimeToOutputMs | Long :測試必須開始輸出內容的最大超時。 |
maxInstrumentationTimeoutMs | Long :完整檢測必須完成的最大超時。 |
checkResults | boolean :是否檢查結果是否有崩潰。 |
isHiddenApiCheckDisabled | boolean :我們是否應該禁用隱藏的 api 檢查。 |
isTestApiCheckDisabled | boolean :我們是否應該禁用測試 api 檢查。 |
isIsolatedStorageDisabled | boolean :我們是否應該禁用隔離存儲。 |
isWindowAnimationDisabled | boolean :我們是否應該禁用窗口動畫。 |
isRestartDisabled | boolean |
instrumentationArgs | : 傳遞給檢測的參數。 |
extraListeners | |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String pkgName,
String testClassName,
String testMethodName)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (String pkgName,
String testClassName,
Integer userId,
Long testTimeoutMs)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
userId | Integer :要針對其運行測試的用戶的 ID。可以為空。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (String pkgName,
String testClassName)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (String pkgName,
String testClassName,
Long testTimeoutMs)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (ITestDevice device,
String runner,
String pkgName,
String testClassName,
String testMethodName,
Integer userId,
Long testTimeoutMs,
Long maxTimeToOutputMs,
Long maxInstrumentationTimeoutMs,
boolean checkResults,
boolean isHiddenApiCheckDisabled,
boolean isTestApiCheckDisabled,
boolean isIsolatedStorageDisabled,
instrumentationArgs,
extraListeners)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
device | ITestDevice :運行檢測的設備。 |
runner | String |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
userId | Integer :要針對其運行測試的用戶的 ID。可以為空。 |
testTimeoutMs | Long :應用於每個測試用例的超時時間(以毫秒為單位)。 |
maxTimeToOutputMs | Long :測試必須開始輸出內容的最大超時。 |
maxInstrumentationTimeoutMs | Long :完整檢測必須完成的最大超時。 |
checkResults | boolean :是否檢查結果是否有崩潰。 |
isHiddenApiCheckDisabled | boolean :我們是否應該禁用隱藏的 api 檢查。 |
isTestApiCheckDisabled | boolean :我們是否應該禁用測試 api 檢查。 |
isIsolatedStorageDisabled | boolean :我們是否應該禁用隔離存儲。 |
instrumentationArgs | : 傳遞給檢測的參數。 |
extraListeners | |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
運行設備測試
public final boolean runDeviceTests (String runner,
String pkgName,
String testClassName,
String testMethodName)
運行已安裝的檢測包的方法。之後立即使用getLastDeviceRunResults()
獲取結果的詳細信息。
參數 |
---|
runner | String :要使用的檢測運行器。 |
pkgName | String :要運行的包的名稱。 |
testClassName | String :要運行的測試類的名稱。 |
testMethodName | String : 要運行的類中的測試方法的名稱。 |
退貨 |
---|
boolean | 如果它成功而沒有失敗,則為真。否則為假。 |
設置Abi
public final void setAbi (IAbi abi)
public final void setTestInformation (TestInformation testInformation)
參數 |
---|
testInformation | TestInformation |
卸載包
public final String uninstallPackage (String pkgName)
卸載設備上的軟件包。
參數 |
---|
pkgName | String : 要卸載的 Android 包 |
卸載包
public final String uninstallPackage (ITestDevice device,
String pkgName)
卸載設備上的包
參數 |
---|
device | ITestDevice :應該卸載包的設備。 |
pkgName | String : 要卸載的 Android 包 |