use of junit.framework.TestCase in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
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 android_frameworks_base by crdroidandroid.
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);
}
use of junit.framework.TestCase in project android_frameworks_base by crdroidandroid.
the class AndroidTestRunnerTest method testRunTestWithAndroidTestCaseInSuite.
public void testRunTestWithAndroidTestCaseInSuite() throws Exception {
mAndroidTestRunner.setTestClassName(OneAndroidTestTestCase.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 android_frameworks_base by crdroidandroid.
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);
}
Aggregations