FileDocCategorySizeDatePackage
LoadingTestCollector.javaAPI DocAndroid 1.5 API1717Wed May 06 22:42:02 BST 2009junit.runner

LoadingTestCollector

public class LoadingTestCollector extends ClassPathTestCollector
An implementation of a TestCollector that loads all classes on the class path and tests whether it is assignable from Test or provides a static suite method.
see
TestCollector {@hide} - Not needed for 1.0 SDK

Fields Summary
TestCaseClassLoader
fLoader
Constructors Summary
public LoadingTestCollector()

		fLoader= new TestCaseClassLoader();
	
Methods Summary
java.lang.ClassclassFromFile(java.lang.String classFileName)

		String className= classNameFromFile(classFileName);
		if (!fLoader.isExcluded(className))
			return fLoader.loadClass(className, false);
		return null;
	
booleanhasPublicConstructor(java.lang.Class testClass)

		try {
			TestSuite.getTestConstructor(testClass);
		} catch(NoSuchMethodException e) {
			return false;
		}
		return true;
	
booleanhasSuiteMethod(java.lang.Class testClass)

		try {
			testClass.getMethod(BaseTestRunner.SUITE_METHODNAME, new Class[0]);
	 	} catch(Exception e) {
	 		return false;
		}
		return true;
	
protected booleanisTestClass(java.lang.String classFileName)

	
		try {
			if (classFileName.endsWith(".class")) {
				Class testClass= classFromFile(classFileName);
				return (testClass != null) && isTestClass(testClass);
			}
		} 
		catch (ClassNotFoundException expected) {
		}
		catch (NoClassDefFoundError notFatal) {
		} 
		return false;
	
booleanisTestClass(java.lang.Class testClass)

		if (hasSuiteMethod(testClass))
			return true;
		if (Test.class.isAssignableFrom(testClass) &&
			Modifier.isPublic(testClass.getModifiers()) &&
			hasPublicConstructor(testClass)) 
			return true;
		return false;