您的位置:首页 > 其它

Unable to find instrumentation target package的问题

2014-07-12 19:34 393 查看
本例为以下DemoDao类进行单元测试

----------------新建DemoDao.java--------------

package com.neter.test.dao;

import android.util.Log;

public class DemoDao{

public void save(){

Log.i("DemoDao", "用来测试的方法");

}



}

----------------新建DemoDaoTest.java--------------

package com.neter.test.dao;

import android.test.AndroidTestCase;

import android.util.Log;

public class DemoDaoTest extends AndroidTestCase {

public void testSave() {

new DemoDao().save();

Log.i("DemoDaoTest", "测试");

}

}

-------------------------------AndroidManifest.xml--------------------------

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.neter.test.dao"

android:versionCode="1"

android:versionName="1.0">

<uses-sdk android:minSdkVersion="8" />

<application android:icon="@drawable/icon" android:label="@string/app_name">

<uses-library android:name="android.test.runner"/>

<activity android:name=".MainActivity"

android:label="@string/app_name">

<intent-filter>

<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />

</intent-filter>

</activity>

</application>

<instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="com.neter.test.dao" android:label="Testing"></instrumentation>

</manifest>

上面配置文件中

MainActivity为android程序入口,请自已新建代码略

<uses-library android:name="android.test.runner"/>不可修改

android:name="android.test.InstrumentationTestRunner不可修改

android:label="Testing"可不写

如出现Test run failed:Unable to find instrumentation target package

是因为 android:targetPackage="com.neter.test.dao" 必须和

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.neter.test.dao"

package相同的包名
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐