IsolatedHostTest

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

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


Implements a TradeFed runner that uses a subprocess to execute the tests in a low-dependency environment instead of executing them on the main process.

This runner assumes that all of the jars configured are in the same test directory and launches the subprocess in that directory. Since it must choose a working directory for the subprocess, and many tests benefit from that directory being the test directory, this was the best compromise available.

Summary

Public constructors

IsolatedHostTest()

Public methods

void addAllExcludeAnnotation( notAnnotations)

Adds a ERROR(/Set) of annotations to exclude if a tests if marked with it.

void addAllExcludeFilters( filters)

Adds the ERROR(/Set) of filters of which tests to exclude.

void addAllIncludeAnnotation( annotations)

Adds a ERROR(/Set) of annotations to include if a tests if marked with it.

void addAllIncludeFilters( filters)

Adds the ERROR(/Set) of filters of which tests to include.

void addExcludeAnnotation(String notAnnotation)

Adds an annotation to exclude if a tests if marked with it.

void addExcludeFilter(String filter)

Adds a filter of which tests to exclude.

void addIncludeAnnotation(String annotation)

Adds an annotation to include if a tests if marked with it.

void addIncludeFilter(String filter)

Adds a filter of which tests to include.

void clearExcludeAnnotations()

Delete all the exclude annotations currently tracked.

void clearExcludeFilters()

Delete all the exclude filters currently tracked.

void clearIncludeAnnotations()

Delete all the include annotations currently tracked.

void clearIncludeFilters()

Delete all the include filters currently tracked.

String compileClassPath()

Creates a classpath for the subprocess that includes the needed jars to run the tests

compileCommandArgs(String classpath, File artifactsDir)

Assembles the command arguments to execute the subprocess runner.

void deleteTempFiles()
File getCoverageExecFile()
getExcludeAnnotations()

Returns the current ERROR(/Set) of annotations to exclude.

getExcludeFilters()

Returns the current ERROR(/Set) of exclude filters.

getIncludeAnnotations()

Returns the current ERROR(/Set) of annotations to include.

getIncludeFilters()

Returns the current ERROR(/Set) of include filters.

void run(TestInformation testInfo, ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setBuild(IBuildInfo build)

void setCollectTestsOnly(boolean shouldCollectTest)

Enables or disables test collection mode

void setConfiguration(IConfiguration configuration)

Injects the IConfiguration in use.

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

Protected methods

String compileLdLibraryPathInner(String androidHostOut)

We call this version from the unit test, and directly pass ANDROID_HOST_OUT.

File getJarFile(String jarName, TestInformation testInfo)

Copied over from HostTest to mimic its unit test harnessing.

void setServer(ServerSocket server)

Public constructors

IsolatedHostTest

public IsolatedHostTest ()

Public methods

addAllExcludeAnnotation

public void addAllExcludeAnnotation ( notAnnotations)

Adds a ERROR(/Set) of annotations to exclude if a tests if marked with it.

Parameters
notAnnotations

addAllExcludeFilters

public void addAllExcludeFilters ( filters)

Adds the ERROR(/Set) of filters of which tests to exclude.

Parameters
filters

addAllIncludeAnnotation

public void addAllIncludeAnnotation ( annotations)

Adds a ERROR(/Set) of annotations to include if a tests if marked with it.

Parameters
annotations

addAllIncludeFilters

public void addAllIncludeFilters ( filters)

Adds the ERROR(/Set) of filters of which tests to include.

Parameters
filters

addExcludeAnnotation

public void addExcludeAnnotation (String notAnnotation)

Adds an annotation to exclude if a tests if marked with it.

Parameters
notAnnotation String

addExcludeFilter

public void addExcludeFilter (String filter)

Adds a filter of which tests to exclude.

Parameters
filter String

addIncludeAnnotation

public void addIncludeAnnotation (String annotation)

Adds an annotation to include if a tests if marked with it.

Parameters
annotation String

addIncludeFilter

public void addIncludeFilter (String filter)

Adds a filter of which tests to include.

Parameters
filter String

clearExcludeAnnotations

public void clearExcludeAnnotations ()

Delete all the exclude annotations currently tracked.

clearExcludeFilters

public void clearExcludeFilters ()

Delete all the exclude filters currently tracked.

clearIncludeAnnotations

public void clearIncludeAnnotations ()

Delete all the include annotations currently tracked.

clearIncludeFilters

public void clearIncludeFilters ()

Delete all the include filters currently tracked.

compileClassPath

public String compileClassPath ()

Creates a classpath for the subprocess that includes the needed jars to run the tests

Returns
String a string specifying the colon separated classpath.

compileCommandArgs

public  compileCommandArgs (String classpath, 
                File artifactsDir)

Assembles the command arguments to execute the subprocess runner.

Parameters
classpath String

artifactsDir File

Returns

deleteTempFiles

public void deleteTempFiles ()

getCoverageExecFile

public File getCoverageExecFile ()

Returns
File

getExcludeAnnotations

public  getExcludeAnnotations ()

Returns the current ERROR(/Set) of annotations to exclude.

Returns

getExcludeFilters

public  getExcludeFilters ()

Returns the current ERROR(/Set) of exclude filters.

Returns

getIncludeAnnotations

public  getIncludeAnnotations ()

Returns the current ERROR(/Set) of annotations to include.

Returns

getIncludeFilters

public  getIncludeFilters ()

Returns the current ERROR(/Set) of include filters.

Returns

run

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
testInfo TestInformation: The TestInformation object containing useful information to run tests.

listener ITestInvocationListener: the ITestInvocationListener of test results

Throws
DeviceNotAvailableException

setBuild

public void setBuild (IBuildInfo build)

Parameters
build IBuildInfo

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

Enables or disables test collection mode

setConfiguration

public void setConfiguration (IConfiguration configuration)

Injects the IConfiguration in use.

Parameters
configuration IConfiguration

setDebug

public void setDebug (boolean debug)

Parameters
debug boolean

uploadTestArtifacts

public void uploadTestArtifacts (File logDir, 
                ITestInvocationListener listener)

Parameters
logDir File

listener ITestInvocationListener

useRavenwoodResources

public boolean useRavenwoodResources ()

Returns
boolean

useRobolectricResources

public boolean useRobolectricResources ()

Returns
boolean

Protected methods

compileLdLibraryPathInner

protected String compileLdLibraryPathInner (String androidHostOut)

We call this version from the unit test, and directly pass ANDROID_HOST_OUT. We need it because Java has no API to set environmental variables.

Parameters
androidHostOut String

Returns
String

getJarFile

protected File getJarFile (String jarName, 
                TestInformation testInfo)

Copied over from HostTest to mimic its unit test harnessing.

Inspect several location where the artifact are usually located for different use cases to find our jar.

Parameters
jarName String

testInfo TestInformation

Returns
File

setServer

protected void setServer (ServerSocket server)

Parameters
server ServerSocket