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)

添加要排除的测试的过滤器的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)

尽最大努力尝试为给定的ERROR(/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 是否应该运行禁用的测试。

领域

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

getAfterTestCmd

public  getAfterTestCmd ()

获取要在 GTest 之后运行的 shell 命令。

退货

getBeforeTestCmd

public  getBeforeTestCmd ()

获取要在 GTest 之前运行的 shell 命令。

退货

获取排除过滤器

public  getExcludeFilters ()

返回排除过滤器的当前ERROR(/Set)

退货

getFileExclusionFilterRegex

public  getFileExclusionFilterRegex ()

获取正则表达式以排除某些文件的执行。

退货

getGTestFlags

public  getGTestFlags ()

获取附加标志值以传递给本机测试的 shell 命令。

退货

getIncludeFilters

public  getIncludeFilters ()

返回包含过滤器的当前ERROR(/Set)

退货

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

设置Abi

public void setAbi (IAbi abi)

参数
abi IAbi

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

分裂

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

getAllGTestFlags

protected String getAllGTestFlags (String path)

获取所有 GTest 标志以传递到 adb shell 命令的帮助程序。

参数
path String :设备上二进制文件的完整路径。

退货
String应传递给 GTest 的所有 GTest 标志的ERROR(/String)

投掷
DeviceNotAvailableException

获取配置

protected IConfiguration getConfiguration ()

返回测试配置。

退货
IConfiguration一个 IConfiguration

获取异常消息

protected String getExceptionMessage (Exception e)

尽最大努力尝试为给定的ERROR(/Exception)检索有意义的简短描述消息

参数
e ExceptionERROR(/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