" : message);
+ }
+
+ /**
+ * Wrapper around a print writer that filters out common noise from stack
+ * traces, making it easier to see the actual failure.
+ */
+ private static class FilteringWriter extends PrintWriter {
+ public FilteringWriter(Writer out) {
+ super(out);
+ }
+
+ @Override
+ public void println(String s) {
+ for (String filtered : DEFAULT_TRACE_FILTERS) {
+ if (s.contains(filtered)) {
+ return;
+ }
+ }
+
+ super.println(s);
+ }
+ }
+}
diff --git a/tests-sync/src/com/zutubi/android/junitreport/JUnitReportTestRunner.java b/tests-sync/src/com/zutubi/android/junitreport/JUnitReportTestRunner.java
new file mode 100644
index 000000000..863e17f65
--- /dev/null
+++ b/tests-sync/src/com/zutubi/android/junitreport/JUnitReportTestRunner.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2010 Zutubi Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.zutubi.android.junitreport;
+
+import android.os.Bundle;
+import android.test.AndroidTestRunner;
+import android.test.InstrumentationTestRunner;
+
+/**
+ * Custom test runner that adds a {@link JUnitReportListener} to the underlying
+ * test runner in order to capture test results in an XML report. You may use
+ * this class in place of {@link InstrumentationTestRunner} in your test
+ * project's manifest, and/or specify it to your Ant build using the test.runner
+ * property.
+ *
+ * This runner behaves identically to the default, with the added side-effect of
+ * producing a JUnit XML report. The report format is similar to that produced
+ * by the Ant JUnit task's XML formatter, making it compatible with existing
+ * tools that can process that format. See {@link JUnitReportListener} for
+ * further details.
+ *
+ * This runner accepts the following arguments:
+ *
+ * - reportFilePath: path of the file to write the XML report to, in the
+ * target application's data area (default: junit-report.xml).
+ * - filterTraces: if true, stack traces in test failure reports will be
+ * filtered to remove noise such as framework methods (default: true)
+ *
+ * These arguments may be specified as follows:
+ *
+ *
+ * {@code adb shell am instrument -w -e reportFile my-report-file.xml}
+ *
+ */
+public class JUnitReportTestRunner extends InstrumentationTestRunner {
+ /**
+ * Path, relative to the target applications file root, at which to write the report file.
+ */
+ private static final String ARG_REPORT_FILE_PATH = "reportFilePath";
+ /**
+ * If true, stack traces in the report will be filtered to remove common noise (e.g. framework
+ * methods).
+ */
+ private static final String ARG_FILTER_TRACES = "filterTraces";
+ /**
+ * Default path of the report file.
+ */
+ private static final String DEFAULT_REPORT_FILE = "junit-report.xml";
+
+ private JUnitReportListener mListener;
+ private String mReportFilePath;
+ private boolean mFilterTraces = true;
+
+ @Override
+ public void onCreate(Bundle arguments) {
+ if (arguments != null) {
+ mReportFilePath = arguments.getString(ARG_REPORT_FILE_PATH);
+ mFilterTraces = arguments.getBoolean(ARG_FILTER_TRACES, true);
+ }
+
+ if (mReportFilePath == null) {
+ mReportFilePath = DEFAULT_REPORT_FILE;
+ }
+
+ super.onCreate(arguments);
+ }
+
+ @Override
+ protected AndroidTestRunner getAndroidTestRunner() {
+ AndroidTestRunner runner = new AndroidTestRunner();
+ mListener = new JUnitReportListener(getTargetContext(), mReportFilePath, mFilterTraces);
+ runner.addTestListener(mListener);
+ return runner;
+ }
+
+ @Override
+ public void finish(int resultCode, Bundle results) {
+ if (mListener != null) {
+ mListener.close();
+ }
+
+ super.finish(resultCode, results);
+ }
+}
diff --git a/tests/src/com/todoroo/astrid/ActivityTests.java b/tests/src/com/todoroo/astrid/ActivityTests.java
deleted file mode 100644
index 24ee77fb5..000000000
--- a/tests/src/com/todoroo/astrid/ActivityTests.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.todoroo.astrid;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import android.test.suitebuilder.TestSuiteBuilder;
-
-/**
- * A test suite containing activity-related tests
- */
-public class ActivityTests extends TestSuite {
-
- public static Test suite() {
- return new TestSuiteBuilder(ActivityTests.class)
- .includePackages("com.todoroo.astrid.activity")
- .build();
- }
-}
diff --git a/tests/src/com/todoroo/astrid/AllTests.java b/tests/src/com/todoroo/astrid/AllTests.java
index ee8584ee1..0c715e0da 100644
--- a/tests/src/com/todoroo/astrid/AllTests.java
+++ b/tests/src/com/todoroo/astrid/AllTests.java
@@ -46,10 +46,6 @@ public class AllTests extends TestSuite {
public static Test suite() {
return new TestSuiteBuilder(AllTests.class)
- .excludePackages(
- "com.todoroo.astrid.gtasks",
- "com.todoroo.astrid.producteev",
- "com.todoroo.astrid.sync.repeats")
.build();
}
}
diff --git a/tests/src/com/todoroo/astrid/ContinuousTests.java b/tests/src/com/todoroo/astrid/ContinuousTests.java
deleted file mode 100644
index 543024650..000000000
--- a/tests/src/com/todoroo/astrid/ContinuousTests.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.todoroo.astrid;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import android.test.suitebuilder.TestSuiteBuilder;
-
-/**
- * A test suite containing all tests for ApiDemos.
- *
- * To run all suites found in this apk:
- * $ adb shell am instrument -w \
- * com.example.android.apis.tests/android.test.InstrumentationTestRunner
- *
- * To run just this suite from the command line:
- * $ adb shell am instrument -w \
- * -e class com.example.android.apis.AllTests \
- * com.example.android.apis.tests/android.test.InstrumentationTestRunner
- *
- * To run an individual test case, e.g. {@link com.example.android.apis.os.MorseCodeConverterTest}:
- * $ adb shell am instrument -w \
- * -e class com.example.android.apis.os.MorseCodeConverterTest \
- * com.example.android.apis.tests/android.test.InstrumentationTestRunner
- *
- * To run an individual test, e.g. {@link com.example.android.apis.os.MorseCodeConverterTest#testCharacterS()}:
- * $ adb shell am instrument -w \
- * -e class com.example.android.apis.os.MorseCodeConverterTest#testCharacterS \
- * com.example.android.apis.tests/android.test.InstrumentationTestRunner
- */
-public class ContinuousTests extends TestSuite {
-
- public static Test suite() {
- return new TestSuiteBuilder(ContinuousTests.class)
- .excludePackages(
- "com.todoroo.astrid.gtasks",
- "com.todoroo.astrid.producteev",
- "com.todoroo.astrid.sync.repeats")
- .build();
- }
-}
diff --git a/tests/src/com/todoroo/astrid/NightlyTests.java b/tests/src/com/todoroo/astrid/NightlyTests.java
deleted file mode 100644
index ee32fb7b9..000000000
--- a/tests/src/com/todoroo/astrid/NightlyTests.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.todoroo.astrid;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import android.test.suitebuilder.TestSuiteBuilder;
-
-/**
- * A test suite containing activity-related tests
- */
-public class NightlyTests extends TestSuite {
-
- public static Test suite() {
- return new TestSuiteBuilder(NightlyTests.class)
- .includeAllPackagesUnderHere()
- .build();
- }
-
-
-}