use of junit.framework.TestCase in project platform_frameworks_base by android.
the class AndroidTestRunnerTest method testRunTestWithAndroidTestCaseInNestedSuite.
public void testRunTestWithAndroidTestCaseInNestedSuite() throws Exception {
mAndroidTestRunner.setTestClassName(AndroidTestCaseTestSuite.class.getName(), null);
TestListenerStub testListenerStub = new TestListenerStub();
mAndroidTestRunner.addTestListener(testListenerStub);
mAndroidTestRunner.runTest();
assertTrue(testListenerStub.saw("testOneAndroid"));
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
for (TestCase testCase : testCases) {
assertSame(mStubContext, ((AndroidTestCase) testCase).getContext());
}
}
use of junit.framework.TestCase 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.TestCase 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.TestCase in project platform_frameworks_base by android.
the class AndroidTestRunnerTest method testSetTestClassWithTestSuiteProvider.
public void testSetTestClassWithTestSuiteProvider() throws Exception {
mAndroidTestRunner.setTestClassName(SampleTestSuiteProvider.class.getName(), null);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
List<String> testNames = Lists.newArrayList();
for (TestCase testCase : testCases) {
testNames.add(testCase.getName());
}
// Use the test suite provided by the interface method rather than the static suite method.
assertEquals(Arrays.asList("testOne"), testNames);
}
use of junit.framework.TestCase in project platform_frameworks_base by android.
the class AndroidTestRunnerTest method testRunSingleTestMethod.
public void testRunSingleTestMethod() throws Exception {
String testMethodName = "testTwo";
mAndroidTestRunner.setTestClassName(TwoTestTestCase.class.getName(), testMethodName);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
List<String> testNames = Lists.newArrayList();
for (TestCase testCase : testCases) {
testNames.add(testCase.getName());
}
assertEquals(Arrays.asList(testMethodName), testNames);
}
Aggregations