I'm attempting to use the JUnit-based testing framework supplied with 
Android 1.0r1...and I'm baffled.

I found the tests associated with the ApiDemos in the SDK. In the 
AllTests class, it says to run:

adb shell am instrument -w \
com.example.android.apis.tests/android.test.InstrumentationTestRunner

I do that, and I get:

INSTRUMENTATION_FAILED: 
com.example.android.apis.tests/android.test.InstrumentationTestRunner

and DDMS gives me an "Unable to find instrumentation info for..." warning.

But, that's OK, I want to run my own tests.

So, in a fresh activityCreator-created project, I:

1. Create an AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android";
                package="xyz.test"
                android:versionCode="1"
                android:versionName="1.0.0">
        <application>
                <uses-library android:name="android.test.runner" />
        </application>
        <instrumentation
                android:name="android.test.InstrumentationTestRunner"
                android:targetPackage="xyz"
                android:label="Tests for the heck of it"/>
</manifest>

2. Make a suite class in my xyz.test package:

public class XYZSuite extends TestSuite {
        public static Test suite() {
                return(new TestSuiteBuilder(XYZSuite.class)
                                .includeAllPackagesUnderHere()
                                .build());
        }
}

3. Make a stupid test class in an xyz.test.foo sub-package:

public class SampleTest extends AndroidTestCase {
        protected void setUp() {
                // do something here
        }
        
        protected void tearDown() {
                // do something here
        }
        
        public void testStupid() {
                assert(true);
        }
        
        public void testStupider() {
                assert(false);
        }
}

4. Build and install the APK for all this on the emulator, bundling in a 
JAR of classes in the xyz namespace that I (eventually) want to test.

5. Run:

adb shell am instrument -w \
xyz.test/android.test.InstrumentationTestRunner

...and it too fails with INSTRUMENTATION_FAILED. This time, I get a 
different warning from DDMS:

"Unable to find instrumentation target package: xyz"

Where am I going wrong?

Thanks in advance!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com
_The Busy Coder's Guide to Android Development_ Version 1.3 Published!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to