use of junit.framework.Test in project platform_frameworks_base by android.
the class TestCaseUtil method getTests.
private static List<? extends Test> getTests(Test test, boolean flatten, Set<Class<?>> seen) {
List<Test> testCases = Lists.newArrayList();
if (test != null) {
Test workingTest = null;
/*
* If we want to run a single TestCase method only, we must not
* invoke the suite() method, because we will run all test methods
* of the class then.
*/
if (test instanceof TestCase && ((TestCase) test).getName() == null) {
workingTest = invokeSuiteMethodIfPossible(test.getClass(), seen);
}
if (workingTest == null) {
workingTest = test;
}
if (workingTest instanceof TestSuite) {
TestSuite testSuite = (TestSuite) workingTest;
Enumeration enumeration = testSuite.tests();
while (enumeration.hasMoreElements()) {
Test childTest = (Test) enumeration.nextElement();
if (flatten) {
testCases.addAll(getTests(childTest, flatten, seen));
} else {
testCases.add(childTest);
}
}
} else {
testCases.add(workingTest);
}
}
return testCases;
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class ListTestCaseNames method getTestCaseNames.
public static List<String> getTestCaseNames(TestSuite suite) {
// TODO: deprecate this method and move all callers to use getTestNames
List<Test> tests = Collections.<Test>list(suite.tests());
ArrayList<String> testCaseNames = new ArrayList<String>();
for (Test test : tests) {
if (test instanceof TestCase) {
testCaseNames.add(((TestCase) test).getName());
} else if (test instanceof TestSuite) {
testCaseNames.addAll(getTestCaseNames((TestSuite) test));
}
}
return testCaseNames;
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class InstrumentationTestRunnerTest method assertTestRunnerCalledWithExpectedParameters.
private void assertTestRunnerCalledWithExpectedParameters(String expectedTestClassName, String expectedTestMethodName) {
Test test = mStubAndroidTestRunner.getTest();
assertContentsInOrder(ListTestCaseNames.getTestNames((TestSuite) test), new TestDescriptor(expectedTestClassName, expectedTestMethodName));
assertTrue(mInstrumentationTestRunner.isStarted());
assertFalse(mInstrumentationTestRunner.isFinished());
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class TestCaseUtilTest method testCreateTestForTestCaseWithSuiteMethod.
public void testCreateTestForTestCaseWithSuiteMethod() throws Exception {
Test test = TestCaseUtil.createTestSuite(OneTestTestCaseWithSuite.class);
assertEquals(1, test.countTestCases());
}
use of junit.framework.Test in project platform_frameworks_base by android.
the class TestCaseUtilTest method testCreateTestForTestCase.
public void testCreateTestForTestCase() throws Exception {
Test test = TestCaseUtil.createTestSuite(OneTestTestCase.class);
assertEquals(1, test.countTestCases());
}
Aggregations