测试库
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) 返回提供额外调试信息的 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 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 ()
删除当前跟踪的所有包含过滤器。
获取测试后命令
publicgetAfterTestCmd ()
获取在 GTest 之后运行的 shell 命令。
退货 | |
---|---|
获取测试前命令
publicgetBeforeTestCmd ()
获取在 GTest 之前运行的 shell 命令。
退货 | |
---|---|
获取文件排除过滤器正则表达式
publicgetFileExclusionFilterRegex ()
获取正则表达式以排除某些文件的执行。
退货 | |
---|---|
获取GTestFlags
publicgetGTestFlags ()
获取要传递给本机测试的 shell 命令的其他标志值。
退货 | |
---|---|
获取最大测试时间毫秒
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 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 |
获取所有GTestFlags
protected String getAllGTestFlags (String path)
帮助程序获取所有 GTest 标志以传递到 adb shell 命令中。
参数 | |
---|---|
path | String :设备上二进制文件的完整路径。 |
退货 | |
---|---|
String | 应传递给 GTest 的所有 GTest 标志的String |
投掷 | |
---|---|
DeviceNotAvailableException |
获取异常消息
protected String getExceptionMessage (Exception e)
尽最大努力尝试为给定的Exception
有意义的简短描述性消息
参数 | |
---|---|
e | Exception : Exception |
退货 | |
---|---|
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 |