use of junit.framework.TestCase in project android_frameworks_base by ResurrectionRemix.
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 android_frameworks_base by ResurrectionRemix.
the class TestSuiteBuilder method build.
/**
* Call this method once you've configured your builder as desired.
*
* @return The suite containing the requested tests.
*/
public final TestSuite build() {
rootSuite = new TestSuite(getSuiteName());
// Keep track of current class so we know when to create a new sub-suite.
currentClassname = null;
try {
for (TestMethod test : testGrouping.getTests()) {
if (satisfiesAllPredicates(test)) {
addTest(test);
}
}
if (testCases.size() > 0) {
for (TestCase testCase : testCases) {
if (satisfiesAllPredicates(new TestMethod(testCase))) {
addTest(testCase);
}
}
}
} catch (Exception exception) {
Log.i("TestSuiteBuilder", "Failed to create test.", exception);
TestSuite suite = new TestSuite(getSuiteName());
suite.addTest(new FailedToCreateTests(exception));
return suite;
}
return rootSuite;
}
use of junit.framework.TestCase in project android_frameworks_base by ResurrectionRemix.
the class AndroidTestRunnerTest method testSetTestClassWithTestSuite.
public void testSetTestClassWithTestSuite() throws Exception {
mAndroidTestRunner.setTestClassName(SampleTestSuite.class.getName(), null);
List<TestCase> testCases = mAndroidTestRunner.getTestCases();
List<String> testNames = Lists.newArrayList();
for (TestCase testCase : testCases) {
testNames.add(testCase.getName());
}
assertEquals(Arrays.asList("testOne", "testOne", "testTwo"), testNames);
}
use of junit.framework.TestCase in project android_frameworks_base by ResurrectionRemix.
the class TestCaseUtilTest method testGetTestCaseNamesForTestCaseWithSuiteMethod.
public void testGetTestCaseNamesForTestCaseWithSuiteMethod() throws Exception {
TestCase testCase = new OneTestTestCaseWithSuite();
List<String> testCaseNames = TestCaseUtil.getTestCaseNames(testCase, false);
assertEquals(1, testCaseNames.size());
assertTrue(testCaseNames.get(0).endsWith("testOne"));
}
use of junit.framework.TestCase in project android_frameworks_base by ResurrectionRemix.
the class ListTestCaseNames method getTestNames.
/**
* Returns a list of test class and method names for each TestCase in suite.
*/
public static List<TestDescriptor> getTestNames(TestSuite suite) {
List<Test> tests = Collections.<Test>list(suite.tests());
ArrayList<TestDescriptor> testNames = new ArrayList<TestDescriptor>();
for (Test test : tests) {
if (test instanceof TestCase) {
String className = test.getClass().getName();
String testName = ((TestCase) test).getName();
testNames.add(new TestDescriptor(className, testName));
} else if (test instanceof TestSuite) {
testNames.addAll(getTestNames((TestSuite) test));
}
}
return testNames;
}
Aggregations