Build 1.0_r1(from source)

android.test.suitebuilder
Class TestSuiteBuilder

java.lang.Object
  extended by android.test.suitebuilder.TestSuiteBuilder
Direct Known Subclasses:
InstrumentationTestSuiteBuilder, SmokeTestSuiteBuilder, UnitTestSuiteBuilder

public class TestSuiteBuilder
extends Object

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


Nested Class Summary
static class TestSuiteBuilder.FailedToCreateTests
          A special TestCase used to indicate a failure during the build() step.
 
Constructor Summary
TestSuiteBuilder(Class clazz)
          The given name is automatically prefixed with the package containing the tests to be run.
TestSuiteBuilder(String name, ClassLoader classLoader)
           
 
Method Summary
 TestSuiteBuilder addRequirements(List<com.android.internal.util.Predicate<TestMethod>> predicates)
          Exclude tests that fail to satisfy all of the given predicates.
 TestSuiteBuilder addRequirements(com.android.internal.util.Predicate<TestMethod>... predicates)
          Exclude tests that fail to satisfy all of the given predicates.
 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.
protected  String getSuiteName()
          Subclasses use this method to determine the name of the suite.
protected  TestGrouping getTestGrouping()
           
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TestSuiteBuilder

public 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 - 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

public TestSuiteBuilder(String name,
                        ClassLoader classLoader)
Method Detail

includePackages

public TestSuiteBuilder includePackages(String... packageNames)
Include all tests that satisfy the requirements in the given packages and all sub-packages, unless otherwise specified.

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

excludePackages

public TestSuiteBuilder excludePackages(String... packageNames)
Exclude all tests in the given packages and all sub-packages, unless otherwise specified.

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

addRequirements

public TestSuiteBuilder addRequirements(List<com.android.internal.util.Predicate<TestMethod>> predicates)
Exclude tests that fail to satisfy all of the given predicates.

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

includeAllPackagesUnderHere

public final TestSuiteBuilder includeAllPackagesUnderHere()
Include all junit tests that satisfy the requirements in the calling class' package and all sub-packages.

Returns:
The builder for method chaining.

named

public 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 - Prefix of name to give the suite being built.
Returns:
The builder for method chaining.

build

public final TestSuite build()
Call this method once you've configured your builder as desired.

Returns:
The suite containing the requested tests.

getSuiteName

protected String getSuiteName()
Subclasses use this method to determine the name of the suite.

Returns:
The package and suite name combined.

addRequirements

public final TestSuiteBuilder addRequirements(com.android.internal.util.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 - Predicates to add to the list of requirements.
Returns:
The builder for method chaining.

getTestGrouping

protected TestGrouping getTestGrouping()
Returns:
the test package that represents the packages that were included for our test suite. Not needed for 1.0 SDK.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature