use of android.test.suitebuilder.TestMethod in project android_frameworks_base by ParanoidAndroid.
the class InstrumentationTestRunner method onCreate.
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
mArguments = arguments;
// Apk paths used to search for test classes when using TestSuiteBuilders.
String[] apkPaths = { getTargetContext().getPackageCodePath(), getContext().getPackageCodePath() };
ClassPathPackageInfoSource.setApkPaths(apkPaths);
Predicate<TestMethod> testSizePredicate = null;
Predicate<TestMethod> testAnnotationPredicate = null;
Predicate<TestMethod> testNotAnnotationPredicate = null;
String testClassesArg = null;
boolean logOnly = false;
if (arguments != null) {
// Test class name passed as an argument should override any meta-data declaration.
testClassesArg = arguments.getString(ARGUMENT_TEST_CLASS);
mDebug = getBooleanArgument(arguments, "debug");
mJustCount = getBooleanArgument(arguments, "count");
mSuiteAssignmentMode = getBooleanArgument(arguments, "suiteAssignment");
mPackageOfTests = arguments.getString(ARGUMENT_TEST_PACKAGE);
testSizePredicate = getSizePredicateFromArg(arguments.getString(ARGUMENT_TEST_SIZE_PREDICATE));
testAnnotationPredicate = getAnnotationPredicate(arguments.getString(ARGUMENT_ANNOTATION));
testNotAnnotationPredicate = getNotAnnotationPredicate(arguments.getString(ARGUMENT_NOT_ANNOTATION));
logOnly = getBooleanArgument(arguments, ARGUMENT_LOG_ONLY);
mCoverage = getBooleanArgument(arguments, "coverage");
mCoverageFilePath = arguments.getString("coverageFile");
try {
// Accept either string or int
Object delay = arguments.get(ARGUMENT_DELAY_MSEC);
if (delay != null)
mDelayMsec = Integer.parseInt(delay.toString());
} catch (NumberFormatException e) {
Log.e(LOG_TAG, "Invalid delay_msec parameter", e);
}
}
TestSuiteBuilder testSuiteBuilder = new TestSuiteBuilder(getClass().getName(), getTargetContext().getClassLoader());
if (testSizePredicate != null) {
testSuiteBuilder.addRequirements(testSizePredicate);
}
if (testAnnotationPredicate != null) {
testSuiteBuilder.addRequirements(testAnnotationPredicate);
}
if (testNotAnnotationPredicate != null) {
testSuiteBuilder.addRequirements(testNotAnnotationPredicate);
}
if (testClassesArg == null) {
if (mPackageOfTests != null) {
testSuiteBuilder.includePackages(mPackageOfTests);
} else {
TestSuite testSuite = getTestSuite();
if (testSuite != null) {
testSuiteBuilder.addTestSuite(testSuite);
} else {
// no package or class bundle arguments were supplied, and no test suite
// provided so add all tests in application
testSuiteBuilder.includePackages("");
}
}
} else {
parseTestClasses(testClassesArg, testSuiteBuilder);
}
testSuiteBuilder.addRequirements(getBuilderRequirements());
mTestRunner = getAndroidTestRunner();
mTestRunner.setContext(getTargetContext());
mTestRunner.setInstrumentation(this);
mTestRunner.setSkipExecution(logOnly);
mTestRunner.setTest(testSuiteBuilder.build());
mTestCount = mTestRunner.getTestCases().size();
if (mSuiteAssignmentMode) {
mTestRunner.addTestListener(new SuiteAssignmentPrinter());
} else {
WatcherResultPrinter resultPrinter = new WatcherResultPrinter(mTestCount);
mTestRunner.addTestListener(new TestPrinter("TestRunner", false));
mTestRunner.addTestListener(resultPrinter);
mTestRunner.setPerformanceResultsWriter(resultPrinter);
}
start();
}
use of android.test.suitebuilder.TestMethod in project android_frameworks_base by ParanoidAndroid.
the class HasMethodAnnotationTest method methodHasAnnotation.
private boolean methodHasAnnotation(Class<? extends TestCase> aClass, String methodName, Class<? extends Annotation> expectedClassification) throws NoSuchMethodException {
Method method = aClass.getMethod(methodName);
TestMethod testMethod = new TestMethod(method, aClass);
return new HasMethodAnnotation(expectedClassification).apply(testMethod);
}
use of android.test.suitebuilder.TestMethod in project android_frameworks_base by ParanoidAndroid.
the class HasAnnotationTest method hasExampleAnnotation.
private boolean hasExampleAnnotation(Class<? extends TestCase> aClass, String methodName) throws NoSuchMethodException {
Method method = aClass.getMethod(methodName);
TestMethod testMethod = new TestMethod(method, aClass);
return new HasAnnotation(Example.class).apply(testMethod);
}
use of android.test.suitebuilder.TestMethod in project android_frameworks_base by DirtyUnicorns.
the class HasMethodAnnotationTest method methodHasAnnotation.
private boolean methodHasAnnotation(Class<? extends TestCase> aClass, String methodName, Class<? extends Annotation> expectedClassification) throws NoSuchMethodException {
Method method = aClass.getMethod(methodName);
TestMethod testMethod = new TestMethod(method, aClass);
return new HasMethodAnnotation(expectedClassification).apply(testMethod);
}
use of android.test.suitebuilder.TestMethod in project android_frameworks_base by DirtyUnicorns.
the class HasAnnotationTest method hasExampleAnnotation.
private boolean hasExampleAnnotation(Class<? extends TestCase> aClass, String methodName) throws NoSuchMethodException {
Method method = aClass.getMethod(methodName);
TestMethod testMethod = new TestMethod(method, aClass);
return new HasAnnotation(Example.class).apply(testMethod);
}
Aggregations