ITestSuite

public abstract class ITestSuite
extends Object implements IRemoteTest, IDeviceTest, IBuildReceiver, ISystemStatusCheckerReceiver, IStrictShardableTest, ITestCollector

java.lang.Object
   ↳ com.android.tradefed.testtype.suite.ITestSuite
Known Direct Subclasses
TfSuiteRunner Implementation of ITestSuite which will load tests from TF jars res/config/suite/ folder. 


Abstract class used to run Test Suite. This class provide the base of how the Suite will be run. Each implementation can define the list of tests via the loadTests() method.

Summary

Public constructors

ITestSuite()

Public methods

IBuildInfo getBuildInfo()

Implementation of ITestSuite may require the build info to load the tests.

ITestDevice getDevice()

Get the device under test.

IRemoteTest getTestShard(int shardCount, int shardIndex)

Returns a IRemoteTest for a single shard.

abstract LinkedHashMap<String, IConfiguration> loadTests()

Abstract method to load the tests configuration that will be run.

final void run(ITestInvocationListener listener)

Generic run method for all test loaded from loadTests().

void setBuild(IBuildInfo buildInfo)

void setCollectTestsOnly(boolean shouldCollectTest)

Run the test suite in collector only mode, this requires all the sub-tests to implements this interface too.

void setDevice(ITestDevice device)

Inject the device under test.

void setSystemStatusChecker(List<ISystemStatusChecker> systemCheckers)

Sets the ISystemStatusCheckers from the configuration for the test.

List<ModuleDefinition> shardModules(List<ModuleDefinition> fullList, int shardCount, int shardIndex)

Split the list of tests to run however the implementation see fit.

Public constructors

ITestSuite

ITestSuite ()

Public methods

getBuildInfo

IBuildInfo getBuildInfo ()

Implementation of ITestSuite may require the build info to load the tests.

Returns
IBuildInfo

getDevice

ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

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

loadTests

LinkedHashMap<String, IConfiguration> loadTests ()

Abstract method to load the tests configuration that will be run. Each tests is defined by a IConfiguration and a unique name under which it will report results.

Returns
LinkedHashMap<String, IConfiguration>

run

void run (ITestInvocationListener listener)

Generic run method for all test loaded from loadTests().

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results
Throws
DeviceNotAvailableException

setBuild

void setBuild (IBuildInfo buildInfo)

Parameters
buildInfo IBuildInfo

setCollectTestsOnly

void setCollectTestsOnly (boolean shouldCollectTest)

Run the test suite in collector only mode, this requires all the sub-tests to implements this interface too.

setDevice

void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

setSystemStatusChecker

void setSystemStatusChecker (List<ISystemStatusChecker> systemCheckers)

Sets the ISystemStatusCheckers from the configuration for the test.

Parameters
systemCheckers List

shardModules

List<ModuleDefinition> shardModules (List<ModuleDefinition> fullList, 
                int shardCount, 
                int shardIndex)

Split the list of tests to run however the implementation see fit. Sharding needs to be consistent. It is acceptable to return an empty list if no tests can be run in the shard.

Implement this in order to provide a test suite specific sharding. The default implementation strictly split by number of tests which is not always optimal.

Parameters
fullList List: the initial full list of ModuleDefinition containing all the tests that need to run.
shardCount int: the total number of shard that need to run.
shardIndex int: the index of the current shard that needs to run.
Returns
List<ModuleDefinition> a list of ModuleDefinition that need to run in the current shard.