use of junit.framework.TestCase in project android_frameworks_base by ParanoidAndroid.
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 ParanoidAndroid.
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 ParanoidAndroid.
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 ParanoidAndroid.
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 ParanoidAndroid.
the class SmokeTestRunner method getAllTests.
/**
* Returns a single testcase for each app to launch
*/
@Override
public TestSuite getAllTests() {
final TestSuite suite = new TestSuite(SUITE_NAME);
final PackageManager pm = getTargetContext().getPackageManager();
final List<ResolveInfo> apps = ProcessErrorsTest.getLauncherActivities(pm);
final TestCase setupTest = new ProcessErrorsTest() {
@Override
public void runTest() throws Exception {
testSetUpConditions();
}
};
setupTest.setName("testSetUpConditions");
suite.addTest(setupTest);
final TestCase postBootTest = new ProcessErrorsTest() {
@Override
public void runTest() throws Exception {
testNoProcessErrorsAfterBoot();
}
};
postBootTest.setName("testNoProcessErrorsAfterBoot");
suite.addTest(postBootTest);
for (final ResolveInfo app : apps) {
final TestCase appTest = new ProcessErrorsTest() {
@Override
public void runTest() throws Exception {
final Set<ProcessError> errSet = new HashSet<ProcessError>();
final Collection<ProcessError> errProcs = runOneActivity(app);
if (errProcs != null) {
errSet.addAll(errProcs);
}
if (!errSet.isEmpty()) {
fail(String.format("Got %d errors:\n%s", errSet.size(), reportWrappedListContents(errSet)));
}
}
};
appTest.setName(app.activityInfo.name);
suite.addTest(appTest);
}
final TestCase asyncErrorTest = new ProcessErrorsTest() {
@Override
public void runTest() throws Exception {
testZZReportAsyncErrors();
}
};
asyncErrorTest.setName("testAsynchronousErrors");
suite.addTest(asyncErrorTest);
return suite;
}
Aggregations