Most visited

Recently visited

Added in API level 1

TestSuiteBuilder

public class TestSuiteBuilder
extends Object

java.lang.Object
   ↳ android.test.suitebuilder.TestSuiteBuilder


Build suites based on a combination of included packages, excluded packages, and predicates that must be satisfied.

Summary

Nested classes

class TestSuiteBuilder.FailedToCreateTests

A special TestCase used to indicate a failure during the build() step. 

Public constructors

TestSuiteBuilder(Class clazz)

The given name is automatically prefixed with the package containing the tests to be run.

TestSuiteBuilder(String name, ClassLoader classLoader)

Public methods

TestSuiteBuilder addRequirements(List<Predicate<TestMethod>> predicates)

Exclude tests that fail to satisfy all of the given predicates.

final TestSuiteBuilder addRequirements(Predicate...<TestMethod> predicates)

Exclude tests that fail to satisfy all of the given predicates.

final TestSuite build()

Call this method once you've configured your builder as desired.

TestSuiteBuilder excludePackages(String... packageNames)

Exclude all tests in the given packages and all sub-packages, unless otherwise specified.

final TestSuiteBuilder includeAllPackagesUnderHere()

Include all junit tests that satisfy the requirements in the calling class' package and all sub-packages.

TestSuiteBuilder includePackages(String... packageNames)

Include all tests that satisfy the requirements in the given packages and all sub-packages, unless otherwise specified.

TestSuiteBuilder named(String newSuiteName)

Override the default name for the suite being built.

Protected methods

String getSuiteName()

Subclasses use this method to determine the name of the suite.

Inherited methods

From class java.lang.Object

Public constructors

TestSuiteBuilder

Added in API level 1
TestSuiteBuilder (Class clazz)

The given name is automatically prefixed with the package containing the tests to be run. If more than one package is specified, the first is used.

Parameters
clazz Class: Use the class from your .apk. Use the class name for the test suite name. Use the class' classloader in order to load classes for testing. This is needed when running in the emulator.

TestSuiteBuilder

Added in API level 1
TestSuiteBuilder (String name, 
                ClassLoader classLoader)

Parameters
name String
classLoader ClassLoader

Public methods

addRequirements

Added in API level 1
TestSuiteBuilder addRequirements (List<Predicate<TestMethod>> predicates)

Exclude tests that fail to satisfy all of the given predicates.

Parameters
predicates List: Predicates to add to the list of requirements.
Returns
TestSuiteBuilder The builder for method chaining.

addRequirements

Added in API level 1
TestSuiteBuilder addRequirements (Predicate...<TestMethod> predicates)

Exclude tests that fail to satisfy all of the given predicates. If you call this method, you probably also want to call named(String) to override the default suite name.

Parameters
predicates Predicate: Predicates to add to the list of requirements.
Returns
TestSuiteBuilder The builder for method chaining.

build

Added in API level 1
TestSuite build ()

Call this method once you've configured your builder as desired.

Returns
TestSuite The suite containing the requested tests.

excludePackages

Added in API level 1
TestSuiteBuilder excludePackages (String... packageNames)

Exclude all tests in the given packages and all sub-packages, unless otherwise specified.

Parameters
packageNames String: Names of packages to remove.
Returns
TestSuiteBuilder The builder for method chaining.

includeAllPackagesUnderHere

Added in API level 1
TestSuiteBuilder includeAllPackagesUnderHere ()

Include all junit tests that satisfy the requirements in the calling class' package and all sub-packages.

Returns
TestSuiteBuilder The builder for method chaining.

includePackages

Added in API level 1
TestSuiteBuilder includePackages (String... packageNames)

Include all tests that satisfy the requirements in the given packages and all sub-packages, unless otherwise specified.

Parameters
packageNames String: Names of packages to add.
Returns
TestSuiteBuilder The builder for method chaining.

named

Added in API level 1
TestSuiteBuilder named (String newSuiteName)

Override the default name for the suite being built. This should generally be called if you call addRequirements(com.android.internal.util.Predicate[]) to make it clear which tests will be included. The name you specify is automatically prefixed with the package containing the tests to be run. If more than one package is specified, the first is used.

Parameters
newSuiteName String: Prefix of name to give the suite being built.
Returns
TestSuiteBuilder The builder for method chaining.

Protected methods

getSuiteName

Added in API level 1
String getSuiteName ()

Subclasses use this method to determine the name of the suite.

Returns
String The package and suite name combined.

Hooray!