aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2010-04-29 17:00:02 -0700
committerBrett Chabot <brettchabot@android.com>2010-04-29 17:09:55 -0700
commit6aedffc0019916afb2f3e1453fa2e14bedbe9cf8 (patch)
treed5034762399f75e283b45dd2c21f07d2567e97fc
parentb1abf9ed13963de9733782c8f28b03b2008832b9 (diff)
downloadsdk-6aedffc0019916afb2f3e1453fa2e14bedbe9cf8.zip
sdk-6aedffc0019916afb2f3e1453fa2e14bedbe9cf8.tar.gz
sdk-6aedffc0019916afb2f3e1453fa2e14bedbe9cf8.tar.bz2
Add more console logs during ADT test run.
This is intended to give the user more visibility the exact progress of the test run. And also better notification of failures. Also tweak the ADT launch action so it reports its terminated when the test runner thread is no longer active. Related bug 7976 Change-Id: Idb258dfa1c15d6937d505bd86add208b4d09d526
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java2
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java74
2 files changed, 55 insertions, 21 deletions
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java
index fcb859a..2bde545 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/AndroidJUnitLaunchAction.java
@@ -239,7 +239,7 @@ class AndroidJUnitLaunchAction implements IAndroidLaunchAction {
* @see org.eclipse.debug.core.model.ITerminate#isTerminated()
*/
public boolean isTerminated() {
- return mIsTerminated;
+ return mIsTerminated || isInterrupted();
}
/**
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java
index 0a045bc..461fd9d 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/runtime/RemoteAdtTestRunner.java
@@ -33,7 +33,7 @@ import java.io.IOException;
* Supports Eclipse JUnit execution of Android tests.
* <p/>
* Communicates back to a Eclipse JDT JUnit client via a socket connection.
- *
+ *
* @see org.eclipse.jdt.internal.junit.runner.RemoteTestRunner for more details on the protocol
*/
@SuppressWarnings("restriction")
@@ -41,17 +41,17 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
private AndroidJUnitLaunchInfo mLaunchInfo;
private TestExecution mExecution;
-
+
/**
* Initialize the JDT JUnit test runner parameters from the {@code args}.
- *
- * @param args name-value pair of arguments to pass to parent JUnit runner.
+ *
+ * @param args name-value pair of arguments to pass to parent JUnit runner.
* @param launchInfo the Android specific test launch info
*/
protected void init(String[] args, AndroidJUnitLaunchInfo launchInfo) {
defaultInit(args);
mLaunchInfo = launchInfo;
- }
+ }
/**
* Runs a set of tests, and reports back results using parent class.
@@ -65,13 +65,13 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
* <li>The test execution result for each test method. Expects individual notifications of
* the test execution start, any failures, and the end of the test execution.</li>
* <li>The end of the test run, with its elapsed time.</li>
- * </ol>
+ * </ol>
* <p/>
* In order to satisfy this, this method performs two actual Android instrumentation runs.
* The first is a 'log only' run that will collect the test tree data, without actually
* executing the tests, and send it back to JDT JUnit. The second is the actual test execution,
* whose results will be communicated back in real-time to JDT JUnit.
- *
+ *
* @param testClassNames ignored - the AndroidJUnitLaunchInfo will be used to determine which
* tests to run.
* @param testName ignored
@@ -81,16 +81,16 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
public void runTests(String[] testClassNames, String testName, TestExecution execution) {
// hold onto this execution reference so it can be used to report test progress
mExecution = execution;
-
- RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(mLaunchInfo.getAppPackage(),
- mLaunchInfo.getRunner(), mLaunchInfo.getDevice());
+
+ RemoteAndroidTestRunner runner = new RemoteAndroidTestRunner(mLaunchInfo.getAppPackage(),
+ mLaunchInfo.getRunner(), mLaunchInfo.getDevice());
if (mLaunchInfo.getTestClass() != null) {
if (mLaunchInfo.getTestMethod() != null) {
runner.setMethodName(mLaunchInfo.getTestClass(), mLaunchInfo.getTestMethod());
- } else {
+ } else {
runner.setClassName(mLaunchInfo.getTestClass());
- }
+ }
}
if (mLaunchInfo.getTestPackage() != null) {
@@ -102,6 +102,8 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
runner.setLogOnly(true);
TestCollector collector = new TestCollector();
try {
+ AdtPlugin.printToConsole(mLaunchInfo.getProject(), "Collecting test information");
+
runner.run(collector);
if (collector.getErrorMessage() != null) {
// error occurred during test collection.
@@ -111,6 +113,9 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
return;
}
notifyTestRunStarted(collector.getTestCaseCount());
+ AdtPlugin.printToConsole(mLaunchInfo.getProject(),
+ "Sending test information to Eclipse");
+
collector.sendTrees(this);
// now do real execution
@@ -118,23 +123,24 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
if (mLaunchInfo.isDebugMode()) {
runner.setDebug(true);
}
+ AdtPlugin.printToConsole(mLaunchInfo.getProject(), "Running tests...");
runner.run(new TestRunListener());
} catch (IOException e) {
reportError(String.format(LaunchMessages.RemoteAdtTestRunner_RunIOException_s,
e.getMessage()));
}
}
-
+
/**
* Main entry method to run tests
- *
+ *
* @param programArgs JDT JUnit program arguments to be processed by parent
* @param junitInfo the {@link AndroidJUnitLaunchInfo} containing info about this test ru
*/
public void runTests(String[] programArgs, AndroidJUnitLaunchInfo junitInfo) {
init(programArgs, junitInfo);
run();
- }
+ }
/**
* Stop the current test run.
@@ -147,7 +153,7 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
protected void stop() {
if (mExecution != null) {
mExecution.stop();
- }
+ }
}
private void notifyTestRunEnded(long elapsedTime) {
@@ -161,14 +167,14 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
* @param errorMessage
*/
private void reportError(String errorMessage) {
- AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(),
+ AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(),
String.format(LaunchMessages.RemoteAdtTestRunner_RunFailedMsg_s, errorMessage));
// is this needed?
//notifyTestRunStopped(-1);
}
/**
- * TestRunListener that communicates results in real-time back to JDT JUnit
+ * TestRunListener that communicates results in real-time back to JDT JUnit
*/
private class TestRunListener implements ITestRunListener {
@@ -189,8 +195,8 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
} else {
statusString = MessageIds.TEST_FAILED;
}
- TestReferenceFailure failure =
- new TestReferenceFailure(new TestCaseReference(test),
+ TestReferenceFailure failure =
+ new TestReferenceFailure(new TestCaseReference(test),
statusString, trace, null);
mExecution.getListener().notifyTestFailed(failure);
}
@@ -234,5 +240,33 @@ public class RemoteAdtTestRunner extends RemoteTestRunner {
TestCaseReference testId = new TestCaseReference(test);
mExecution.getListener().notifyTestStarted(testId);
}
+
+ }
+
+ /**
+ * Override parent to get extra logs.
+ */
+ @Override
+ protected boolean connect() {
+ boolean result = super.connect();
+ if (!result) {
+ AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(),
+ "Connect to Eclipse test result listener failed");
+ }
+ return result;
+ }
+
+ /**
+ * Override parent to dump error message to console.
+ */
+ @Override
+ public void runFailed(String message, Exception exception) {
+ if (exception != null) {
+ AdtPlugin.logAndPrintError(exception, mLaunchInfo.getProject().getName(),
+ "Test launch failed: %s", message);
+ } else {
+ AdtPlugin.printErrorToConsole(mLaunchInfo.getProject(), "Test launch failed: %s",
+ message);
+ }
}
} \ No newline at end of file