G測試庫
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) 添加要排除的測試的過濾器的 |
void | addAllIncludeFilters ( filters) addAllIncludeFilters ( filters) 添加要包含哪些測試的過濾器的 |
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 () 返回排除過濾器的當前 | |
getFileExclusionFilterRegex () 獲取正則表達式以排除某些文件的執行。 | |
getGTestFlags () 獲取附加標誌值以傳遞給本機測試的 shell 命令。 | |
getIncludeFilters () 返回包含過濾器的當前 | |
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) 注入正在使用的 |
void | setModuleName (String moduleName) 設置要運行的 Android 原生測試模塊。 |
void | setShardCount (int shardCount) 設置此測試的分片數。 |
void | setShardIndex (int shardIndex) 設置此測試的分片索引。 |
split (int shardCountHint) |
受保護的方法 | |
---|---|
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) 盡最大努力嘗試為給定的 |
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) 返回提供額外調試信息的 |
abstract String | loadFilter (String path) 定義獲取過濾器方法。 |
void | setRunDisabled (boolean runDisabled) 設置 GTest 是否應該運行禁用的測試。 |
領域
FILTER_EXTENSION
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_OUTPUT
protected static final String GTEST_XML_OUTPUT
公共構造函數
G測試庫
public GTestBase ()
公共方法
添加排除過濾器
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 ()
刪除當前跟踪的所有包含過濾器。
getAfterTestCmd
publicgetAfterTestCmd ()
獲取要在 GTest 之後運行的 shell 命令。
退貨 | |
---|---|
getBeforeTestCmd
publicgetBeforeTestCmd ()
獲取要在 GTest 之前運行的 shell 命令。
退貨 | |
---|---|
getFileExclusionFilterRegex
publicgetFileExclusionFilterRegex ()
獲取正則表達式以排除某些文件的執行。
退貨 | |
---|---|
getGTestFlags
publicgetGTestFlags ()
獲取附加標誌值以傳遞給本機測試的 shell 命令。
退貨 | |
---|---|
getMaxTestTimeMs
public long getMaxTestTimeMs ()
獲取 gtest 運行的最長時間。
退貨 | |
---|---|
long |
獲取模塊名稱
public String getModuleName ()
獲取要運行的 Android 本機測試模塊。
退貨 | |
---|---|
String | 要運行的本機測試模塊的名稱,如果未設置則為 null |
getRunDisabledTests
public boolean getRunDisabledTests ()
獲取 GTest 是否應該運行禁用的測試。
退貨 | |
---|---|
boolean | 如果應運行禁用的測試,則為 True,否則為 false |
獲取運行時提示
public long getRuntimeHint ()
以毫秒為單位返回測試的預期運行時間。該時間用於負載平衡分片執行
退貨 | |
---|---|
long |
getShardCount
public int getShardCount ()
返回當前分片數。
退貨 | |
---|---|
int |
獲取ShardIndex
public int getShardIndex ()
獲取本次測試的分片索引。
退貨 | |
---|---|
int |
getTestFilterKey
public String getTestFilterKey ()
獲取測試過濾器鍵。
退貨 | |
---|---|
String |
獲取測試模塊
public String getTestModule ()
獲取模塊名稱。
退貨 | |
---|---|
String |
isCollectTestsOnly
public boolean isCollectTestsOnly ()
獲取是否只調用測試二進製文件來收集適用測試用例的列表。
退貨 | |
---|---|
boolean |
isEnableXmlOutput
public boolean isEnableXmlOutput ()
獲取是否使用 gtest xml 輸出作為測試結果。
退貨 | |
---|---|
boolean |
已分片
public boolean isSharded ()
獲取 isSharded 標誌。
退貨 | |
---|---|
boolean |
setCollectTestsOnly
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 |
分裂
publicsplit (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 |
getAllGTestFlags
protected String getAllGTestFlags (String path)
獲取所有 GTest 標誌以傳遞到 adb shell 命令的幫助程序。
參數 | |
---|---|
path | String :設備上二進製文件的完整路徑。 |
退貨 | |
---|---|
String | 應傳遞給 GTest 的所有 GTest 標誌的ERROR(/String) |
投擲 | |
---|---|
DeviceNotAvailableException |
獲取異常消息
protected String getExceptionMessage (Exception e)
盡最大努力嘗試為給定的ERROR(/Exception)
檢索有意義的簡短描述消息
參數 | |
---|---|
e | Exception : ERROR(/Exception) |
退貨 | |
---|---|
String | 一條短信 |
getGTestCmdLine
protected String getGTestCmdLine (String fullPath, String flags)
構建要運行的 gtest 命令的幫助程序方法。
參數 | |
---|---|
fullPath | String :設備上 gtest 二進製文件的絕對文件系統路徑 |
flags | String :gtest 執行標誌 |
退貨 | |
---|---|
String | 為 gtest 運行的 shell 命令行 |
getGTestCmdLineWrapper
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 |
getGTestListener
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 |