測試庫

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 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 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