Methods Summary |
---|
protected junit.textui.ResultPrinter | createPrinter()
return new CoreTestPrinter(System.out, fFlags);
|
private junit.framework.Test | createTest(java.lang.String testCase)Tries to create a Test instance from a given string. The string might
either specify a class only or a class plus a method name, separated by
a "#".
int p = testCase.indexOf("#");
if (p != -1) {
String testName = testCase.substring(p + 1);
testCase = testCase.substring(0, p);
return TestSuite.createTest(Class.forName(testCase), testName);
} else {
return getTest(testCase);
}
|
protected junit.framework.TestResult | createTestResult()
return new CoreTestResult(fFlags, fTimeout);
|
public junit.framework.TestResult | doRun(junit.framework.Test suite, boolean wait)
setPrinter(createPrinter());
/*
* Make sure the original suite is unreachable after we have
* created the new one, so GC can dispose terminated tests.
*/
suite = new CoreTestSuite(suite, fFlags, fStep, null);
return super.doRun(suite, wait);
|
public static void | main(java.lang.String[] args)Provides our main entry point.
Logger.global.setLevel(Level.OFF);
System.out.println(
"--------------------------------------------------");
System.out.println("Android Core Libraries Test Suite");
System.out.println("Version 1.0");
System.out.println(
"Copyright (c) 2009 The Android Open Source Project");
System.out.println("");
CoreTestRunner testRunner = new CoreTestRunner();
try {
TestResult r = testRunner.start(args);
System.out.println(
"--------------------------------------------------");
if (!r.wasSuccessful()) {
System.exit(FAILURE_EXIT);
} else {
System.exit(SUCCESS_EXIT);
}
} catch(Exception e) {
System.err.println(e.getMessage());
System.exit(EXCEPTION_EXIT);
}
|
private void | showHelp()Prints a help screen on the console.
System.out.println("Usage: run-core-tests {<param>} <test>");
System.out.println();
System.out.println("Where <test> is a class name, optionally followed");
System.out.println("by \"#\" and a method name, and <param> is one of");
System.out.println("the following:");
System.out.println();
System.out.println(" --include-all");
System.out.println(" --exclude-all");
System.out.println(" --include-android-only");
System.out.println(" --exclude-android-only");
System.out.println(" --include-broken-tests");
System.out.println(" --exclude-broken-tests");
System.out.println(" --include-known-failures");
System.out.println(" --exclude-known-failures");
System.out.println(" --include-normal-tests");
System.out.println(" --exclude-normal-tests");
System.out.println(" --include-side-effects");
System.out.println(" --exclude-side-effects");
System.out.println();
System.out.println(" --known-failures-must-fail");
System.out.println(" --known-failures-must-pass");
System.out.println(" --timeout <seconds>");
// System.out.println(" --find-side-effect <test>");
System.out.println(" --isolate-all");
System.out.println(" --isolate-none");
System.out.println(" --verbose");
System.out.println(" --help");
System.out.println();
System.out.println("Default parameters are:");
System.out.println();
if (IS_DALVIK) {
System.out.println(" --include-android-only");
System.out.println(" --exclude-broken-tests");
System.out.println(" --include-known-failures");
System.out.println(" --include-normal-tests");
System.out.println(" --include-side-effects");
System.out.println(" --known-failures-must-fail");
} else {
System.out.println(" --exclude-android-only");
System.out.println(" --exclude-broken-tests");
System.out.println(" --include-known-failures");
System.out.println(" --include-normal-tests");
System.out.println(" --include-side-effects");
System.out.println(" --known-failures-must-pass");
}
System.out.println();
|
protected junit.framework.TestResult | start(java.lang.String[] args)
String testName = null;
// String victimName = null;
boolean wait = false;
if (IS_DALVIK) {
fFlags = DEFAULT_FLAGS_DALVIK;
} else {
fFlags = DEFAULT_FLAGS_NON_DALVIK;
}
for (int i= 0; i < args.length; i++) {
if (args[i].startsWith("--")) {
if (args[i].equals("--wait")) {
wait = true;
} else if (args[i].equals("--include-all")) {
fFlags = fFlags | CoreTestSuite.RUN_ALL_TESTS;
} else if (args[i].equals("--exclude-all")) {
fFlags = fFlags & ~CoreTestSuite.RUN_ALL_TESTS;
} else if (args[i].equals("--include-android-only")) {
fFlags = fFlags | CoreTestSuite.RUN_ANDROID_ONLY;
} else if (args[i].equals("--exclude-android-only")) {
fFlags = fFlags & ~CoreTestSuite.RUN_ANDROID_ONLY;
} else if (args[i].equals("--include-broken-tests")) {
fFlags = fFlags | CoreTestSuite.RUN_BROKEN_TESTS;
} else if (args[i].equals("--exclude-broken-tests")) {
fFlags = fFlags & ~CoreTestSuite.RUN_BROKEN_TESTS;
} else if (args[i].equals("--include-known-failures")) {
fFlags = fFlags | CoreTestSuite.RUN_KNOWN_FAILURES;
} else if (args[i].equals("--exclude-known-failures")) {
fFlags = fFlags & ~CoreTestSuite.RUN_KNOWN_FAILURES;
} else if (args[i].equals("--include-normal-tests")) {
fFlags = fFlags | CoreTestSuite.RUN_NORMAL_TESTS;
} else if (args[i].equals("--exclude-normal-tests")) {
fFlags = fFlags & ~CoreTestSuite.RUN_NORMAL_TESTS;
} else if (args[i].equals("--include-side-effects")) {
fFlags = fFlags | CoreTestSuite.RUN_SIDE_EFFECTS;
} else if (args[i].equals("--exclude-side-effects")) {
fFlags = fFlags & ~CoreTestSuite.RUN_SIDE_EFFECTS;
} else if (args[i].equals("--known-failures-must-fail")) {
fFlags = fFlags | CoreTestSuite.INVERT_KNOWN_FAILURES;
} else if (args[i].equals("--known-failures-must-pass")) {
fFlags = fFlags & ~CoreTestSuite.INVERT_KNOWN_FAILURES;
} else if (args[i].equals("--timeout")) {
fTimeout = Integer.parseInt(args[++i]);
} else if (args[i].equals("--reverse")) {
fFlags = fFlags | CoreTestSuite.REVERSE;
} else if (args[i].equals("--step")) {
fStep = Integer.parseInt(args[++i]);
} else if (args[i].equals("--isolate-all")) {
fFlags = (fFlags | CoreTestSuite.ISOLATE_ALL) &
~CoreTestSuite.ISOLATE_NONE;
} else if (args[i].equals("--isolate-none")) {
fFlags = (fFlags | CoreTestSuite.ISOLATE_NONE) &
~CoreTestSuite.ISOLATE_ALL;
} else if (args[i].equals("--verbose")) {
fFlags = fFlags | CoreTestSuite.VERBOSE;
// } else if (args[i].equals("--find-side-effect")) {
// victimName = args[++i];
} else if (args[i].equals("--dry-run")) {
fFlags = fFlags | CoreTestSuite.DRY_RUN;
} else if (args[i].equals("--help")) {
showHelp();
System.exit(1);
} else {
System.err.println("Unknown argument " + args[i] +
", try --help");
System.exit(1);
}
} else {
testName = args[i];
}
}
if (IS_DALVIK) {
System.out.println("Using Dalvik VM version " +
System.getProperty("java.vm.version"));
} else {
System.out.println("Using Java VM version " +
System.getProperty("java.version"));
}
System.out.println();
try {
return doRun(createTest(testName), wait);
}
catch(Exception e) {
e.printStackTrace();
throw new Exception("Could not create and run test suite: " + e);
}
|