I am currently dealing with some CTS issues for our own device. It comes to my mind that if we can run a single CTS test case just from Eclipse, that would be very helpful for debugging the CTS issues. For example, I have create an Android test project, with the manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="android.content.pm.cts"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="android.content.pm" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
</manifest>
And the source code:
package android.content.pm.cts;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ResolveInfo.DisplayNameComparator;
import android.test.AndroidTestCase;
public class ResolveInfo_DisplayNameComparatorTest extends AndroidTestCase {
private static final String MAIN_ACTION_NAME = "android.intent.action.MAIN";
private static final String SERVICE_NAME = "android.content.pm.cts.activity.PMTEST_SERVICE";
public void testDisplayNameComparator() {
PackageManager pm = getContext().getPackageManager();
DisplayNameComparator dnc = new DisplayNameComparator(pm);
Intent intent = new Intent(MAIN_ACTION_NAME);
ResolveInfo activityInfo = pm.resolveActivity(intent, 0);
intent = new Intent(SERVICE_NAME);
ResolveInfo serviceInfo = pm.resolveService(intent, PackageManager.GET_RESOLVED_FILTER);
assertTrue(dnc.compare(activityInfo, serviceInfo) < 0);
assertTrue(dnc.compare(activityInfo, activityInfo) == 0);
assertTrue(dnc.compare(serviceInfo, activityInfo) > 0);
}
}
When I right click on the project and select "run as android junit test" it just report: Test run failed: Unable to find instrumentation target package: android.content.pm
I know that I might be totally wrong from the beginning. So could anyone please point out a correct way out for me? Thanks a lot!