use of junit.framework.TestCase in project android_frameworks_base by DirtyUnicorns.
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 DirtyUnicorns.
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 android_frameworks_base by DirtyUnicorns.
the class AndroidTestRunner method runTest.
public void runTest(TestResult testResult) {
mTestResult = testResult;
for (TestListener testListener : mTestListeners) {
mTestResult.addListener(testListener);
}
Context testContext = mInstrumentation == null ? mContext : mInstrumentation.getContext();
for (TestCase testCase : mTestCases) {
setContextIfAndroidTestCase(testCase, mContext, testContext);
setInstrumentationIfInstrumentationTestCase(testCase, mInstrumentation);
setPerformanceWriterIfPerformanceCollectorTestCase(testCase, mPerfWriter);
testCase.run(mTestResult);
}
}
use of junit.framework.TestCase in project android_frameworks_base by DirtyUnicorns.
the class AndroidTestRunner method setTestClassName.
@SuppressWarnings("unchecked")
public void setTestClassName(String testClassName, String testMethodName) {
Class testClass = loadTestClass(testClassName);
if (shouldRunSingleTestMethod(testMethodName, testClass)) {
TestCase testCase = buildSingleTestMethod(testClass, testMethodName);
mTestCases = Lists.newArrayList(testCase);
mTestClassName = testClass.getSimpleName();
} else {
setTest(getTest(testClass), testClass);
}
}
use of junit.framework.TestCase in project android_frameworks_base by DirtyUnicorns.
the class AndroidTestRunner method newSingleTestMethod.
private TestCase newSingleTestMethod(Class testClass, String testMethodName, Constructor constructor, Object... args) {
try {
TestCase testCase = (TestCase) constructor.newInstance(args);
testCase.setName(testMethodName);
return testCase;
} catch (IllegalAccessException e) {
runFailed("Could not access test class. Class: " + testClass.getName());
} catch (InstantiationException e) {
runFailed("Could not instantiate test class. Class: " + testClass.getName());
} catch (IllegalArgumentException e) {
runFailed("Illegal argument passed to constructor. Class: " + testClass.getName());
} catch (InvocationTargetException e) {
runFailed("Constructor thew an exception. Class: " + testClass.getName());
}
return null;
}
Aggregations