IsolatedHostTest

public class IsolatedHostTest
extends Object implements IBuildReceiver, IConfigurationReceiver, IRemoteTest, IShardableTest, ITestAnnotationFilterReceiver, ITestCollector, ITestFilterReceiver

java.lang.Object
   ↳ com.android.tradefed.testtype.IsolatedHostTest


实现了一个 TradeFed 运行程序,该运行程序使用子进程在低依赖性环境中执行测试,而不是在主进程中执行测试。

此运行程序假定所有已配置的 jar 都在同一测试目录中,并在该目录中启动子进程。由于它必须为子进程选择一个工作目录,并且许多测试都受益于该目录是测试目录,因此这是可用的最佳折衷方案。

摘要

公共构造函数

IsolatedHostTest()

公共方法

void addAllExcludeAnnotation( notAnnotations)

添加了 ERROR(/Set) 注解,如果测试标记了该注解,则排除相应测试。

void addAllExcludeFilters( filters)

添加了要排除的测试的过滤条件的 ERROR(/Set)

void addAllIncludeAnnotation( annotations)

添加了 ERROR(/Set) 注释,用于指定如果测试标记了该注释,则包含该注释。

void addAllIncludeFilters( filters)

添加了要包含的测试的过滤条件 ERROR(/Set)

void addExcludeAnnotation(String notAnnotation)

添加了一个注解,用于排除标记了该注解的测试。

void addExcludeFilter(String filter)

添加了要排除的测试的过滤条件。

void addIncludeAnnotation(String annotation)

添加一个注释,用于指定是否包含标记了该注释的测试。

void addIncludeFilter(String filter)

添加了用于指定要包含哪些测试的过滤条件。

void clearExcludeAnnotations()

删除当前跟踪的所有排除注释。

void clearExcludeFilters()

删除当前跟踪的所有排除过滤条件。

void clearIncludeAnnotations()

删除当前跟踪的所有 include 注释。

void clearIncludeFilters()

删除当前跟踪的所有包含过滤条件。

String compileClassPath()

为子进程创建类路径,其中包含运行测试所需的 jar

compileCommandArgs(String classpath, File artifactsDir)

组装命令实参以执行子进程运行程序。

void deleteTempFiles()
File getCoverageExecFile()
getExcludeAnnotations()

返回要排除的注释的当前 ERROR(/Set)

getExcludeFilters()

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

getIncludeAnnotations()

返回要包含的注释的当前 ERROR(/Set)

getIncludeFilters()

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

void run(TestInformation testInfo, ITestInvocationListener listener)

运行测试,并将结果报告给监听器。

void setBuild(IBuildInfo build)

void setCollectTestsOnly(boolean shouldCollectTest)

启用或停用测试收集模式

void setConfiguration(IConfiguration configuration)

注入正在使用的 IConfiguration

void setDebug(boolean debug)
split(int shardCount)

split() 的替代版本,还提供尝试运行的 shardCount。

void uploadTestArtifacts(File logDir, ITestInvocationListener listener)
boolean useRavenwoodResources()
boolean useRobolectricResources()

受保护的方法

String compileLdLibraryPathInner(String androidHostOut)

我们从单元测试中调用此版本,并直接传递 ANDROID_HOST_OUT。

File getJarFile(String jarName, TestInformation testInfo)

从 HostTest 复制过来,以模拟其单元测试框架。

void setServer(ServerSocket server)

公共构造函数

IsolatedHostTest

public IsolatedHostTest ()

公共方法

addAllExcludeAnnotation

public void addAllExcludeAnnotation ( notAnnotations)

添加了 ERROR(/Set) 注解,如果测试标记了该注解,则排除相应测试。

参数
notAnnotations

addAllExcludeFilters

public void addAllExcludeFilters ( filters)

添加了要排除的测试的过滤条件的 ERROR(/Set)

参数
filters

addAllIncludeAnnotation

public void addAllIncludeAnnotation ( annotations)

添加了 ERROR(/Set) 注释,用于指定如果测试标记了该注释,则包含该注释。

参数
annotations

addAllIncludeFilters

public void addAllIncludeFilters ( filters)

添加了要包含的测试的过滤条件 ERROR(/Set)

参数
filters

addExcludeAnnotation

public void addExcludeAnnotation (String notAnnotation)

添加了一个注解,用于排除标记了该注解的测试。

参数
notAnnotation String

addExcludeFilter

public void addExcludeFilter (String filter)

添加了要排除的测试的过滤条件。

参数
filter String

addIncludeAnnotation

public void addIncludeAnnotation (String annotation)

添加了一个注解,用于指定是否包含标记了该注解的测试。

参数
annotation String

addIncludeFilter

public void addIncludeFilter (String filter)

添加了用于指定要包含哪些测试的过滤条件。

参数
filter String

clearExcludeAnnotations

public void clearExcludeAnnotations ()

删除当前跟踪的所有排除注释。

clearExcludeFilters

public void clearExcludeFilters ()

删除当前跟踪的所有排除过滤条件。

clearIncludeAnnotations

public void clearIncludeAnnotations ()

删除当前跟踪的所有包含注释。

clearIncludeFilters

public void clearIncludeFilters ()

删除当前跟踪的所有包含过滤条件。

compileClassPath

public String compileClassPath ()

为子进程创建类路径,其中包含运行测试所需的 jar

返回
String 一个字符串,用于指定以英文冒号分隔的类路径。

compileCommandArgs

public  compileCommandArgs (String classpath, 
                File artifactsDir)

组装命令实参以执行子进程运行程序。

参数
classpath String

artifactsDir File

返回

deleteTempFiles

public void deleteTempFiles ()

getCoverageExecFile

public File getCoverageExecFile ()

返回
File

getExcludeAnnotations

public  getExcludeAnnotations ()

返回要排除的注释的当前 ERROR(/Set)

返回

getExcludeFilters

public  getExcludeFilters ()

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

返回

getIncludeAnnotations

public  getIncludeAnnotations ()

返回要包含的注释的当前 ERROR(/Set)

返回

getIncludeFilters

public  getIncludeFilters ()

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

返回

得分

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

运行测试,并将结果报告给监听器。

参数
testInfo TestInformation:包含用于运行测试的实用信息的 TestInformation 对象。

listener ITestInvocationListener:测试结果的 ITestInvocationListener

抛出
DeviceNotAvailableException

setBuild

public void setBuild (IBuildInfo build)

参数
build IBuildInfo

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

启用或停用测试收集模式

setConfiguration

public void setConfiguration (IConfiguration configuration)

注入正在使用的 IConfiguration

参数
configuration IConfiguration

setDebug

public void setDebug (boolean debug)

参数
debug boolean

分解

public  split (int shardCount)

split() 的替代版本,还提供尝试运行的 shardCount。这对于有时无法任意决定的某些测试运行程序非常有用。

参数
shardCount int:尝试的分片数量。

返回
要单独执行的子测试集合,如果测试目前不可分片,则为 null

uploadTestArtifacts

public void uploadTestArtifacts (File logDir, 
                ITestInvocationListener listener)

参数
logDir File

listener ITestInvocationListener

useRavenwoodResources

public boolean useRavenwoodResources ()

返回
boolean

useRobolectricResources

public boolean useRobolectricResources ()

返回
boolean

受保护的方法

compileLdLibraryPathInner

protected String compileLdLibraryPathInner (String androidHostOut)

我们从单元测试中调用此版本,并直接传递 ANDROID_HOST_OUT。我们需要它,因为 Java 没有用于设置环境变量的 API。

参数
androidHostOut String

返回
String

getJarFile

protected File getJarFile (String jarName, 
                TestInformation testInfo)

从 HostTest 复制过来,以模拟其单元测试框架。

检查不同使用情形下工件通常所在的多个位置,以找到我们的 JAR。

参数
jarName String

testInfo TestInformation

返回
File

setServer

protected void setServer (ServerSocket server)

参数
server ServerSocket