From 9c240fe83a141b4d500404e952886c0919ced7d6 Mon Sep 17 00:00:00 2001 From: Muthu Ramadoss Date: Thu, 13 Nov 2008 15:36:09 +0530 Subject: [PATCH] ENHANCEMENT: activitycreator generates 'tests' project for instrumentation. activitycreator script is enhanced to generate 'tests' project along with the main project. The current behavior of generating Activity is extended by generating ActivityTest in 'tests/src' folder. The 'tests' folder follows the example provided asis in 'ApiDemos'. ApiDemos was used as reference project to mimic the project layout for building tests using Instrumentation. From 'tests' project, type: "adb shell am instrument -w [your.package].tests/android.test.InstrumentationTestRunner" to run all tests using Android InstrumentationTestRunner. NOTE: 'tests' is a separate AndroidProject by all means. It has its own AndroidManifest.xml, build.xml, src, res etc., AMEND: Fixed style issues, javadoc Fixed build.template to generate tests/build.xml Removed build.tests.template since its obsolete now. --- scripts/AndroidManifest.tests.template | 21 +++++++++++++++++++++ scripts/build.template | 9 ++++++++- scripts/java_tests_file.template | 21 +++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 scripts/AndroidManifest.tests.template create mode 100644 scripts/java_tests_file.template diff --git a/scripts/AndroidManifest.tests.template b/scripts/AndroidManifest.tests.template new file mode 100644 index 000000000..1f7d827fe --- /dev/null +++ b/scripts/AndroidManifest.tests.template @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/scripts/build.template b/scripts/build.template index 74e845314..9aeaf9869 100644 --- a/scripts/build.template +++ b/scripts/build.template @@ -20,7 +20,8 @@ - + + @@ -60,6 +61,11 @@ else="${basedir}/${outdir-classes}" > + + + @@ -160,6 +166,7 @@ bootclasspath="${android-jar}"> + diff --git a/scripts/java_tests_file.template b/scripts/java_tests_file.template new file mode 100644 index 000000000..7781a33c3 --- /dev/null +++ b/scripts/java_tests_file.template @@ -0,0 +1,21 @@ +package PACKAGE; + +import android.test.ActivityInstrumentationTestCase; + +/** + * This is a simple framework for a test of an Application. See + * {@link android.test.ApplicationTestCase ApplicationTestCase} for more information on + * how to write and extend Application tests. + *

+ * To run this test, you can type: + * adb shell am instrument -w \ + * -e class PACKAGE.ACTIVITY_NAMETest \ + * PACKAGE.tests/android.test.InstrumentationTestRunner + */ +public class ACTIVITY_NAMETest extends ActivityInstrumentationTestCase { + + public ACTIVITY_NAMETest() { + super("PACKAGE", ACTIVITY_NAME.class); + } + +} \ No newline at end of file -- 2.11.0