AndroidJUnitTest

public class AndroidJUnitTest
extends InstrumentationTest implements IRuntimeHintProvider, ITestFileFilterReceiver, ITestFilterReceiver, ITestAnnotationFilterReceiver, IShardableTest

java.lang.Object
   ↳ com.android.tradefed.testtype.InstrumentationTest
     ↳ com.android.tradefed.testtype.AndroidJUnitTest


A Test that runs an instrumentation test package on given device using the android.support.test.runner.AndroidJUnitRunner.

Summary

Fields

public static final String EXCLUDE_COLLECTOR_FILTER_KEY

public static final String INCLUDE_COLLECTOR_FILTER_KEY

Options from the collector side helper library.

public static final String NEW_RUN_LISTENER_ORDER_KEY

instrumentation test runner argument used to enable the new RunListener order on device side.

Public constructors

AndroidJUnitTest()

Public methods

void addAllExcludeAnnotation( excludeAnnotations)

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

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.

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.

long getRuntimeHint()

Return the expected runtime of the test in milliseconds.

boolean isClassOrMethod(String filter)

Return if a string is the name of a Class or a Method.

boolean isRegex(String filter)

Return if a string is a regex for filter.

void run(ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setDeviceSpec(IConfiguration spec)

Guice-injected object, that can influence the instrumentation args.

void setExcludeTestFile(File testFile)

Sets the test file of excludes.

void setIncludeTestFile(File testFile)

Sets the test file of includes.

split(int shardCount)

Alternative version of split() which also provides the shardCount that is attempted to be run.

Protected methods

void setRunnerArgs(IRemoteAndroidTestRunner runner)

Fields

EXCLUDE_COLLECTOR_FILTER_KEY

public static final String EXCLUDE_COLLECTOR_FILTER_KEY

INCLUDE_COLLECTOR_FILTER_KEY

public static final String INCLUDE_COLLECTOR_FILTER_KEY

Options from the collector side helper library.

NEW_RUN_LISTENER_ORDER_KEY

public static final String NEW_RUN_LISTENER_ORDER_KEY

instrumentation test runner argument used to enable the new RunListener order on device side.

Public constructors

AndroidJUnitTest

public AndroidJUnitTest ()

Public methods

addAllExcludeAnnotation

public void addAllExcludeAnnotation ( excludeAnnotations)

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

Parameters
excludeAnnotations

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

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

Parameters
excludeAnnotation 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.

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

getRuntimeHint

public long getRuntimeHint ()

Return the expected runtime of the test in milliseconds. The time is used to load balance sharded execution

Returns
long

isClassOrMethod

public boolean isClassOrMethod (String filter)

Return if a string is the name of a Class or a Method.

Parameters
filter String

Returns
boolean

isRegex

public boolean isRegex (String filter)

Return if a string is a regex for filter.

Parameters
filter String

Returns
boolean

run

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results

Throws
DeviceNotAvailableException

setDeviceSpec

public void setDeviceSpec (IConfiguration spec)

Guice-injected object, that can influence the instrumentation args.

Parameters
spec IConfiguration

setExcludeTestFile

public void setExcludeTestFile (File testFile)

Sets the test file of excludes. Does not ensure that testFile exists or is a file.

Parameters
testFile File

setIncludeTestFile

public void setIncludeTestFile (File testFile)

Sets the test file of includes. Does not ensure that testFile exists or is a file.

Parameters
testFile File

split

public  split (int shardCount)

Alternative version of split() which also provides the shardCount that is attempted to be run. This is useful for some test runner that cannot arbitrarly decide sometimes.

Parameters
shardCount int: the attempted shard count.

Returns
a collection of subtests to be executed separately or null if test is not currently shardable

Protected methods

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

Parameters
runner IRemoteAndroidTestRunner