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!
您看到的错误是因为android操作系统找不到使用软件包“ android.content.pm”安装的应用程序,而eclipse也不了解该项目以便为您安装它,安装要测试的应用程序(以及检查它的程序包实际上是android.content.pm,这可能不是因为它是系统程序包,并且您将无法对此进行检测,因为您的调试签名不一样)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.