views:

31

answers:

2

After I have set up all the unit test cases for my android application I now also want to do functional testing. But I encouter one problem. As I am developping for the HTC Legend I can, by now, only use android platforms up to 2.1. But in some way it seems that the ActivityInstrumentationTestCase2 won't work.

public SupplierSelectoinTest() {
    super("com.sap.catalogue.activities", SupplierSelection.class);
}

This simple piece of code gives me the following error, when I try to run the test:

java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.sap.catalogue.activities/com.sap.catalogue.activities.SupplierSelection }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:371)
at android.test.InstrumentationTestCase.launchActivityWithIntent(InstrumentationTestCase.java:120)
at android.test.InstrumentationTestCase.launchActivity(InstrumentationTestCase.java:98)
at android.test.ActivityInstrumentationTestCase2.getActivity(ActivityInstrumentationTestCase2.java:87)
at com.sap.catalogue.test.acceptance.SupplierSelectoinTest.setUp(SupplierSelectoinTest.java:27)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:430)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1447)

I read through all tutorials and all I get out of it is, that it should work but it doesn't. Anyway, when I switch to android 2.2 (which is no solution for now) and I use the new constructor, where I only need to hand in the activity class and not the pkg string the emulator will run the tests without complaining.

But there has to be a way to get this running in android 2.1!

In addition These are my two Manifest.xml files. The first one, is the one of the application itself. The other one is the one of the test project.

Application Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sap.catalogue"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Catalogue"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    <activity android:name=".activities.CategoryBrowser"></activity>

<activity android:name=".activities.ProductDetails"></activity>
<activity android:name=".activities.ProductSearch"></activity>
<activity android:name=".activities.ProductView"></activity>
<activity android:name=".activities.SupplierSelection"></activity>

</application>
    <uses-sdk android:minSdkVersion="7" />

<uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest> 

Test Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sap.catalogue.test"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">

    <uses-library android:name="android.test.runner" />
    </application>
    <uses-sdk android:minSdkVersion="7" />
    <instrumentation android:targetPackage="com.sap.catalogue" android:name="android.test.InstrumentationTestRunner" />

</manifest> 
A: 

Most probably, you didn't write the activity in the Manifest.xml. Would you share it also?

Edit:

Add this to the test Manifest.xml. I think, this will solve your problem.

<activity android:name="com.sap.catalogue.activities.SupplierSelection"></activity>
Omer
Which one do you mean? The Manifest.xml of the test project or of the application itself?
philgiese
I meant test Manifest.xml. edited.
Omer
Unfortunately it doesn't. Even with this line in the Manifest.xml it gives me exactly the same error.
philgiese