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 {
TestCase testCase = (TestCase) testClass.newInstance();
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());
}
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;
|
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);
}
for (TestCase testCase : mTestCases) {
setContextIfAndroidTestCase(testCase, mContext);
setInstrumentationIfInstrumentationTestCase(testCase, mInstrumentation);
testCase.run(mTestResult);
}
|
public void | setContext(android.content.Context context)
mContext = context;
|
private void | setContextIfAndroidTestCase(junit.framework.Test test, android.content.Context context)
if (AndroidTestCase.class.isAssignableFrom(test.getClass())) {
((AndroidTestCase) test).setContext(context);
}
|
public void | setInstrumentaiton(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).injectInsrumentation(instrumentation);
}
|
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)
|