Methods Summary |
---|
private void | assertContentsInOrder(java.util.List actual, java.lang.String source)
String[] clonedSource = source.clone();
assertEquals("Unexpected number of items.", clonedSource.length, actual.size());
for (int i = 0; i < actual.size(); i++) {
String actualItem = actual.get(i);
String sourceItem = clonedSource[i];
assertEquals("Unexpected item. Index: " + i, sourceItem, actualItem);
}
|
private static java.lang.String | packageFor(java.lang.Class clazz)
String className = clazz.getName();
return className.substring(0, className.lastIndexOf('."));
|
private android.test.suitebuilder.TestSuiteBuilderTest$SuiteExecutionRecorder | runSuite(TestSuiteBuilder builder)
TestSuite suite = builder.build();
SuiteExecutionRecorder recorder = new SuiteExecutionRecorder();
TestResult result = new TestResult();
result.addListener(recorder);
suite.run(result);
return recorder;
|
protected void | setUp()
super.setUp();
testSuiteBuilder = new TestSuiteBuilder(getClass());
|
public void | testExcludePackage()
testSuiteBuilder.includePackages(packageFor(SimpleTest.class),
packageFor(Level1Test.class)).excludePackages(packageFor(Level2Test.class));
TestSuite testSuite = testSuiteBuilder.build();
assertContentsInOrder(getTestCaseNames(testSuite),
"testLevel1", "testAnotherOne", "testSimpleOne", "testSimpleTwo");
|
public void | testIncludeAllPackagesUnderHere()This test calls {@link OuterTest#buildTestsUnderHereRecursively()} to control
the packages under test. The call to {@link TestSuiteBuilder#includeAllPackagesUnderHere()}
is made from there so that only return the example tests.
TestSuite testSuite = new OuterTest().buildTestsUnderHereRecursively();
assertContentsInOrder(getTestCaseNames(testSuite),
"testOuter", "testErrorOne", "testErrorTwo", "testFailOne", "testFailTwo",
"testInstrumentation", "testLevel1", "testLevel2", "testAnotherOne",
"testSimpleOne", "testSimpleTwo", "testNonSmoke", "testSmoke", "testSubclass",
"testSuperclass", "testUnSuppressedMethod");
|
public void | testShouldAddFailingTestsToSuite()
testSuiteBuilder.includePackages(packageFor(FailingTest.class));
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertTrue(recorder.failed("FailingTest.testFailOne"));
assertTrue(recorder.failed("FailingTest.testFailTwo"));
|
public void | testShouldAddTestsWithErrorsToSuite()
testSuiteBuilder.includePackages(packageFor(ErrorTest.class));
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertTrue(recorder.errored("ErrorTest.testErrorOne"));
assertTrue(recorder.errored("ErrorTest.testErrorTwo"));
|
public void | testShouldExcludeSuppressedTests()
testSuiteBuilder.includePackages(packageFor(SuppressedTest.class));
testSuiteBuilder.build();
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertEquals(1, recorder.testsSeen.size());
assertTrue(recorder.passed("PartiallySuppressedTest.testUnSuppressedMethod"));
|
public void | testShouldIncludeTestsInSubPackagesRecursively()
testSuiteBuilder.includePackages(packageFor(Level1Test.class));
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertTrue(recorder.passed("Level1Test.testLevel1"));
assertTrue(recorder.passed("Level2Test.testLevel2"));
|
public void | testShouldOnlyIncludeTestsThatSatisfyAllPredicates()
testSuiteBuilder.includePackages(packageFor(SimpleTest.class))
.addRequirements(testsWhoseNameContains("test"))
.addRequirements(testsWhoseNameContains("Simple"))
.addRequirements(testsWhoseNameContains("Two"));
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertTrue(recorder.passed("SimpleTest.testSimpleTwo"));
|
public void | testShouldRunSimpleTests()
testSuiteBuilder.includePackages(packageFor(SimpleTest.class));
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertTrue(recorder.passed("SimpleTest.testSimpleOne"));
assertTrue(recorder.passed("SimpleTest.testSimpleTwo"));
assertTrue(recorder.passed("AnotherSimpleTest.testAnotherOne"));
|
public void | testShouldRunTestsInheritedFromSuperclass()
testSuiteBuilder.includePackages(packageFor(SubclassTest.class));
SuiteExecutionRecorder recorder = runSuite(testSuiteBuilder);
assertEquals(2, getTestCaseNames(testSuiteBuilder.build()).size());
assertTrue(recorder.passed("SubclassTest.testSubclass"));
assertTrue(recorder.passed("SubclassTest.testSuperclass"));
assertFalse(recorder.saw("SuperclassTest.testSuperclass"));
|
private com.android.internal.util.Predicate | testsWhoseNameContains(java.lang.String string)
return new Predicate<TestMethod>() {
public boolean apply(TestMethod testMethod) {
return testMethod.getName().contains(string);
}
};
|