Methods Summary |
---|
public void | addTestListener(junit.framework.TestListener testListener)
if (testListener != null) {
mTestListeners.add(testListener);
}
|
private junit.framework.TestCase | buildSingleTestMethod(java.lang.Class testClass, java.lang.String testMethodName)
try {
Constructor c = testClass.getConstructor();
return newSingleTestMethod(testClass, testMethodName, c);
} catch (NoSuchMethodException e) {
}
try {
Constructor c = testClass.getConstructor(String.class);
return newSingleTestMethod(testClass, testMethodName, c, testMethodName);
} catch (NoSuchMethodException e) {
}
return null;
|
public void | clearTestListeners()
mTestListeners.clear();
|
protected junit.framework.TestResult | createTestResult()
if (mSkipExecution) {
return new NoExecTestResult();
}
return new TestResult();
|
private junit.framework.Test | getTest(java.lang.Class clazz)
if (TestSuiteProvider.class.isAssignableFrom(clazz)) {
try {
TestSuiteProvider testSuiteProvider =
(TestSuiteProvider) clazz.getConstructor().newInstance();
return testSuiteProvider.getTestSuite();
} catch (InstantiationException e) {
runFailed("Could not instantiate test suite provider. Class: " + clazz.getName());
} catch (IllegalAccessException e) {
runFailed("Illegal access of test suite provider. Class: " + clazz.getName());
} catch (InvocationTargetException e) {
runFailed("Invocation exception test suite provider. Class: " + clazz.getName());
} catch (NoSuchMethodException e) {
runFailed("No such method on test suite provider. Class: " + clazz.getName());
}
}
return getTest(clazz.getName());
|
public java.util.List | getTestCases()
return mTestCases;
|
public java.lang.String | getTestClassName()
return mTestClassName;
|
public junit.framework.TestResult | getTestResult()
return mTestResult;
|
protected java.lang.Class | loadSuiteClass(java.lang.String suiteClassName)
return mContext.getClassLoader().loadClass(suiteClassName);
|
private java.lang.Class | loadTestClass(java.lang.String testClassName)
try {
return (Class<? extends Test>) mContext.getClassLoader().loadClass(testClassName);
} catch (ClassNotFoundException e) {
runFailed("Could not find test class. Class: " + testClassName);
}
return null;
|
private junit.framework.TestCase | newSingleTestMethod(java.lang.Class testClass, java.lang.String testMethodName, java.lang.reflect.Constructor constructor, java.lang.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;
|
protected void | runFailed(java.lang.String message)
throw new RuntimeException(message);
|
public void | runTest()
runTest(createTestResult());
|
public void | runTest(junit.framework.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);
}
|
public void | setContext(android.content.Context context)
mContext = context;
|
private void | setContextIfAndroidTestCase(junit.framework.Test test, android.content.Context context, android.content.Context testContext)
if (AndroidTestCase.class.isAssignableFrom(test.getClass())) {
((AndroidTestCase) test).setContext(context);
((AndroidTestCase) test).setTestContext(testContext);
}
|
public void | setInstrumentaiton(android.app.Instrumentation instrumentation)
setInstrumentation(instrumentation);
|
public void | setInstrumentation(android.app.Instrumentation instrumentation)
mInstrumentation = instrumentation;
|
private void | setInstrumentationIfInstrumentationTestCase(junit.framework.Test test, android.app.Instrumentation instrumentation)
if (InstrumentationTestCase.class.isAssignableFrom(test.getClass())) {
((InstrumentationTestCase) test).injectInstrumentation(instrumentation);
}
|
public void | setPerformanceResultsWriter(android.os.PerformanceCollector.PerformanceResultsWriter writer){@hide} Pending approval for public API.
mPerfWriter = writer;
|
private void | setPerformanceWriterIfPerformanceCollectorTestCase(junit.framework.Test test, android.os.PerformanceCollector.PerformanceResultsWriter writer)
if (PerformanceCollectorTestCase.class.isAssignableFrom(test.getClass())) {
((PerformanceCollectorTestCase) test).setPerformanceResultsWriter(writer);
}
|
void | setSkipExecution(boolean skip)
mSkipExecution = skip;
|
public void | setTest(junit.framework.Test test)
setTest(test, test.getClass());
|
private void | setTest(junit.framework.Test test, java.lang.Class testClass)
mTestCases = (List<TestCase>) TestCaseUtil.getTests(test, true);
if (TestSuite.class.isAssignableFrom(testClass)) {
mTestClassName = TestCaseUtil.getTestName(test);
} else {
mTestClassName = testClass.getSimpleName();
}
|
public void | setTestClassName(java.lang.String testClassName, java.lang.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);
}
|
private boolean | shouldRunSingleTestMethod(java.lang.String testMethodName, java.lang.Class testClass)
return testMethodName != null && TestCase.class.isAssignableFrom(testClass);
|
public void | testEnded(java.lang.String testName)
|
public void | testFailed(int status, junit.framework.Test test, java.lang.Throwable t)
|
public void | testStarted(java.lang.String testName)
|