測試庫

public abstract class GTestBase
extends Object implements IRemoteTest , IConfigurationReceiver , ITestFilterReceiver , IRuntimeHintProvider , ITestCollector , IShardableTest , IAbiReceiver

java.lang.Object
com.android.tradefed.testtype.GTestBase


gTest的基底類

概括

領域

protected static final String FILTER_EXTENSION

protected static final String GTEST_FLAG_FILE

protected static final String GTEST_FLAG_FILTER

protected static final String GTEST_FLAG_LIST_TESTS

protected static final String GTEST_FLAG_PRINT_TIME

protected static final String GTEST_FLAG_RUN_DISABLED_TESTS

protected static final String GTEST_XML_OUTPUT

公共構造函數

GTestBase ()

公共方法

void addAllExcludeFilters ( filters) addAllExcludeFilters ( filters)

新增要排除的測試的過濾器的ERROR(/Set)

void addAllIncludeFilters ( filters) addAllIncludeFilters ( filters)

新增要包含的測試的過濾器的ERROR(/Set)

void addExcludeFilter (String filter)

新增要排除的測試的過濾器。

void addIncludeFilter (String filter)

新增要包含的測試的過濾器。

String cleanFilter (String filter)
void clearExcludeFilters ()

刪除目前追蹤的所有排除過濾器。

void clearIncludeFilters ()

刪除目前追蹤的所有包含過濾器。

IAbi getAbi ()
getAfterTestCmd ()

取得在 GTest 之後運行的 shell 命令。

getBeforeTestCmd ()

取得在 GTest 之前執行的 shell 命令。

getExcludeFilters ()

傳回排除過濾器的目前ERROR(/Set)

getFileExclusionFilterRegex ()

取得正規表示式以排除某些文件的執行。

getGTestFlags ()

取得要傳遞給本機測試的 shell 指令的其他標誌值。

getIncludeFilters ()

傳回包含篩選器的目前ERROR(/Set)

long getMaxTestTimeMs ()

取得 gtest 運行的最長時間。

String getModuleName ()

取得要運行的 Android 本機測試模組。

boolean getRunDisabledTests ()

取得 GTest 是否應該執行已停用的測試。

long getRuntimeHint ()

傳回測試的預期運行時間(以毫秒為單位)。

int getShardCount ()

返回當前分片計數。

int getShardIndex ()

取得本次測試的分片索引。

String getTestFilterKey ()

取得測試過濾器金鑰。

String getTestModule ()

取得模組名稱。

boolean isCollectTestsOnly ()

僅取得呼叫測試二進位檔案來收集適用測試案例的清單。

boolean isEnableXmlOutput ()

取得是否使用 gtest xml 輸出來取得測試結果。

boolean isSharded ()

取得 isSharded 標誌。

void notifyTestExecution (boolean incompleteTestFound, failedTests) notifyTestExecution (boolean incompleteTestFound, failedTests)

通知父級測試執行,以便可以正確處理重試嘗試的包含/排除過濾器。

void setAbi ( IAbi abi)
void setCollectTestsOnly (boolean shouldCollectTest)

啟用或停用測試收集模式

void setConfiguration ( IConfiguration configuration)

注入正在使用的IConfiguration

void setModuleName (String moduleName)

設定Android本機測試模組運作。

void setShardCount (int shardCount)

設定此測試的分片計數。

void setShardIndex (int shardIndex)

設定本次測試的分片索引。

split (int shardCountHint)

split()的替代版本還提供嘗試運行的 shardCount。

受保護的方法

String createFlagFile (String filter)

建立一個包含將通過 --gtest_flagfile 使用的過濾器的文件,以避免 args 大小的任何作業系統限制。

void erasePrependedFileName ( filters, String filename) erasePrependedFileName ( filters, String filename)
String getAllGTestFlags (String path)

幫助程式取得所有 GTest 標誌以傳遞到 adb shell 命令中。

IConfiguration getConfiguration ()

返回測試配置。

String getExceptionMessage (Exception e)

盡最大努力嘗試為給定的Exception有意義的簡短描述性訊息

String getGTestCmdLine (String fullPath, String flags)

建立要執行的 gtest 命令的幫助程式方法。

String getGTestCmdLineWrapper (String fullPath, String flags)

幫助器,允許衍生類別將 gtest 指令包裝在其他工具(chroot、strace、gdb 等)下。

String getGTestFilters (String path)

幫助程式讓測試的 g-test 過濾器運作。

ITestInvocationListener getGTestListener ( ITestInvocationListener listener)

傳回提供額外偵錯資訊的 GTestListener,例如在 mDisabledDuplicateCheck 為 false 時檢測並報告重複測試。

abstract String loadFilter (String path)

定義獲取過濾器方法。

void setRunDisabled (boolean runDisabled)

設定 GTest 是否應執行已停用的測試。

領域

過濾器擴展

protected static final String FILTER_EXTENSION

GTEST_FLAG_FILE

protected static final String GTEST_FLAG_FILE

GTEST_FLAG_FILTER

protected static final String GTEST_FLAG_FILTER

GTEST_FLAG_LIST_TESTS

protected static final String GTEST_FLAG_LIST_TESTS

GTEST_FLAG_PRINT_TIME

protected static final String GTEST_FLAG_PRINT_TIME

GTEST_FLAG_RUN_DISABLED_TESTS

protected static final String GTEST_FLAG_RUN_DISABLED_TESTS

GTEST_XML_輸出

protected static final String GTEST_XML_OUTPUT

公共構造函數

測試庫

public GTestBase ()

公共方法

新增所有排除過濾器

public void addAllExcludeFilters ( filters)

新增要排除的測試的過濾器的ERROR(/Set)

參數
filters

添加所有包含過濾器

public void addAllIncludeFilters ( filters)

新增要包含的測試的過濾器的ERROR(/Set)

參數
filters

新增排除過濾器

public void addExcludeFilter (String filter)

新增要排除的測試的過濾器。

參數
filter String

新增包含過濾器

public void addIncludeFilter (String filter)

新增要包含的測試的過濾器。

參數
filter String

清潔過濾器

public String cleanFilter (String filter)

參數
filter String

退貨
String

清除排除過濾器

public void clearExcludeFilters ()

刪除目前追蹤的所有排除過濾器。

清除包含過濾器

public void clearIncludeFilters ()

刪除目前追蹤的所有包含過濾器。

獲取阿比

public IAbi getAbi ()

退貨
IAbi

取得測試後命令

public  getAfterTestCmd ()

取得在 GTest 之後運行的 shell 命令。

退貨

取得測試前命令

public  getBeforeTestCmd ()

取得在 GTest 之前執行的 shell 命令。

退貨

取得排除過濾器

public  getExcludeFilters ()

傳回排除過濾器的目前ERROR(/Set)

退貨

取得檔案排除過濾器正規表示式

public  getFileExclusionFilterRegex ()

取得正規表示式以排除某些文件的執行。

退貨

取得GTestFlags

public  getGTestFlags ()

取得要傳遞給本機測試的 shell 指令的其他標誌值。

退貨

取得包含過濾器

public  getIncludeFilters ()

傳回包含篩選器的目前ERROR(/Set)

退貨

取得最大測試時間毫秒

public long getMaxTestTimeMs ()

取得 gtest 運行的最長時間。

退貨
long

取得模組名稱

public String getModuleName ()

取得要運行的 Android 本機測試模組。

退貨
String要執行的本機測試模組的名稱,如果未設定則為 null

取得運行禁用測試

public boolean getRunDisabledTests ()

取得 GTest 是否應該執行已停用的測試。

退貨
boolean如果應執行停用的測試,則為 true,否則為 false

取得運行時提示

public long getRuntimeHint ()

傳回測試的預期運行時間(以毫秒為單位)。此時間用於負載平衡分片執行

退貨
long

取得分片計數

public int getShardCount ()

返回當前分片計數。

退貨
int

取得分片索引

public int getShardIndex ()

取得本次測試的分片索引。

退貨
int

取得測試過濾器金鑰

public String getTestFilterKey ()

取得測試過濾器金鑰。

退貨
String

取得測試模組

public String getTestModule ()

取得模組名稱。

退貨
String

僅收集測試

public boolean isCollectTestsOnly ()

僅取得呼叫測試二進位檔案來收集適用測試案例的清單。

退貨
boolean

isEnableXmlOutput

public boolean isEnableXmlOutput ()

取得是否使用 gtest xml 輸出來取得測試結果。

退貨
boolean

已分片

public boolean isSharded ()

取得 isSharded 標誌。

退貨
boolean

通知測試執行

public void notifyTestExecution (boolean incompleteTestFound, 
                 failedTests)

通知父級測試執行,以便可以正確處理重試嘗試的包含/排除過濾器。

參數
incompleteTestFound boolean

failedTests

設定阿比

public void setAbi (IAbi abi)

參數
abi IAbi

僅設定收集測試

public void setCollectTestsOnly (boolean shouldCollectTest)

啟用或停用測試收集模式

設定配置

public void setConfiguration (IConfiguration configuration)

注入正在使用的IConfiguration

參數
configuration IConfiguration

設定模組名稱

public void setModuleName (String moduleName)

設定Android本機測試模組運作。

參數
moduleName String :要執行的本機測試模組的名稱

設定分片數量

public void setShardCount (int shardCount)

設定此測試的分片計數。

參數
shardCount int

設定分片索引

public void setShardIndex (int shardIndex)

設定本次測試的分片索引。

參數
shardIndex int

分裂

public  split (int shardCountHint)

split()的替代版本還提供嘗試運行的 shardCount。這對於某些有時無法隨意決定的測試運行者很有用。

參數
shardCountHint int :嘗試的分片計數。

退貨
要單獨執行的子測試的集合,如果測試目前不可分片,則為null

受保護的方法

建立標誌文件

protected String createFlagFile (String filter)

建立一個包含將通過 --gtest_flagfile 使用的過濾器的文件,以避免 args 大小的任何作業系統限制。

參數
filter String : 過濾字串

退貨
String包含過濾器的檔案的路徑。

投擲
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

擦除前置檔案名

protected void erasePrependedFileName ( filters, 
                String filename)

參數
filters

filename String

取得所有GTestFlags

protected String getAllGTestFlags (String path)

幫助程式取得所有 GTest 標誌以傳遞到 adb shell 命令中。

參數
path String :裝置上二進位檔案的完整路徑。

退貨
String應傳遞給 GTest 的所有 GTest 標誌的String

投擲
DeviceNotAvailableException

取得配置

protected IConfiguration getConfiguration ()

返回測試配置。

退貨
IConfiguration一個 IConfiguration

獲取異常訊息

protected String getExceptionMessage (Exception e)

盡最大努力嘗試為給定的Exception有意義的簡短描述性訊息

參數
e ExceptionException

退貨
String一則簡訊

取得GTestCmdLine

protected String getGTestCmdLine (String fullPath, 
                String flags)

建立要執行的 gtest 命令的幫助程式方法。

參數
fullPath String : 裝置上 gtest 二進位檔案的絕對檔案系統路徑

flags String : gtest 執行標誌

退貨
String為 gtest 運行的 shell 命令列

取得GTestCmdLineWrapper

protected String getGTestCmdLineWrapper (String fullPath, 
                String flags)

幫助器,允許衍生類別將 gtest 指令包裝在其他工具(chroot、strace、gdb 等)下。

參數
fullPath String

flags String

退貨
String

取得GTestFilters

protected String getGTestFilters (String path)

幫助程式讓測試的 g-test 過濾器運作。

請注意,過濾器僅過濾函數名稱(例如:Google Test“Test”);所有 Google 測試「測試用例」都會被考慮。

參數
path String :裝置上二進位檔案的完整路徑。

退貨
String要傳遞給 g-test 的完整過濾器標誌,如果未指定,則為空字串

投擲
DeviceNotAvailableException

取得GTestListener

protected ITestInvocationListener getGTestListener (ITestInvocationListener listener)

傳回提供額外偵錯資訊的 GTestListener,例如在 mDisabledDuplicateCheck 為 false 時檢測並報告重複測試。否則,返回傳入的偵聽器。

參數
listener ITestInvocationListener

退貨
ITestInvocationListener

載入過濾器

protected abstract String loadFilter (String path)

定義獲取過濾器方法。

子類別必須實作如何取得自己的過濾器。

參數
path String :過濾器檔案的完整路徑。

退貨
String過濾字串。

投擲
DeviceNotAvailableException

設定運行禁用

protected void setRunDisabled (boolean runDisabled)

設定 GTest 是否應執行已停用的測試。

參數
runDisabled boolean