AndroidJUnitTest

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

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

Constants

String AJUR

Public constructors

AndroidJUnitTest()

Public methods

void addAllExcludeAnnotation(Set<String> excludeAnnotations)

Adds a Set of annotations to exclude if a tests if marked with it.

void addAllExcludeFilters(Set<String> filters)

Adds the Set of filters of which tests to exclude.

void addAllIncludeAnnotation(Set<String> annotations)

Adds a Set of annotations to include if a tests if marked with it.

void addAllIncludeFilters(Set<String> filters)

Adds the 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.

long getRuntimeHint()

Return the expected runtime of the test in milliseconds.

IRemoteTest getTestShard(int shardCount, int shardIndex)

Returns a IRemoteTest for a single shard.

boolean isClassOrMethod(String filter)

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

void run(ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setExcludeTestFile(File testFile)

Sets the test file of excludes.

void setIncludeTestFile(File testFile)

Sets the test file of includes.

Collection<IRemoteTest> split()

Shard the test into separately runnable chunks.

Protected methods

void setRunnerArgs(IRemoteAndroidTestRunner runner)

Constants

AJUR

String AJUR

Constant Value: "android.support.test.runner.AndroidJUnitRunner"

Public constructors

AndroidJUnitTest

AndroidJUnitTest ()

Public methods

addAllExcludeAnnotation

void addAllExcludeAnnotation (Set<String> excludeAnnotations)

Adds a Set of annotations to exclude if a tests if marked with it.

Parameters
excludeAnnotations Set

addAllExcludeFilters

void addAllExcludeFilters (Set<String> filters)

Adds the Set of filters of which tests to exclude.

Parameters
filters Set

addAllIncludeAnnotation

void addAllIncludeAnnotation (Set<String> annotations)

Adds a Set of annotations to include if a tests if marked with it.

Parameters
annotations Set

addAllIncludeFilters

void addAllIncludeFilters (Set<String> filters)

Adds the Set of filters of which tests to include.

Parameters
filters Set

addExcludeAnnotation

void addExcludeAnnotation (String excludeAnnotation)

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

Parameters
excludeAnnotation String

addExcludeFilter

void addExcludeFilter (String filter)

Adds a filter of which tests to exclude.

Parameters
filter String

addIncludeAnnotation

void addIncludeAnnotation (String annotation)

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

Parameters
annotation String

addIncludeFilter

void addIncludeFilter (String filter)

Adds a filter of which tests to include.

Parameters
filter String

getRuntimeHint

long getRuntimeHint ()

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

Returns
long

getTestShard

IRemoteTest getTestShard (int shardCount, 
                int shardIndex)

Returns a IRemoteTest for a single shard. This must be deterministic and always return the same IRemoteTest for the same input.

Parameters
shardCount int: the number of total shards
shardIndex int: the index of a test shard to return. The value is in range [0, shardCount).
Returns
IRemoteTest a IRemoteTest

isClassOrMethod

boolean isClassOrMethod (String filter)

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

Parameters
filter String
Returns
boolean

run

void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results
Throws
DeviceNotAvailableException

setExcludeTestFile

void setExcludeTestFile (File testFile)

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

Parameters
testFile File

setIncludeTestFile

void setIncludeTestFile (File testFile)

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

Parameters
testFile File

split

Collection<IRemoteTest> split ()

Shard the test into separately runnable chunks.

This will be called before test execution, so injected dependencies (such as the ITestDevice for IDeviceTests) may be null.

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

Protected methods

setRunnerArgs

void setRunnerArgs (IRemoteAndroidTestRunner runner)

Parameters
runner IRemoteAndroidTestRunner