Rob*_*ett 65 eclipse junit android unit-testing
尝试使用Android项目从Eclipse运行单元测试时出现此错误.在Android偏好设置中,Instrumentation Test Runners列表为空.
[2009-06-17 23:57:51 - MyApp]错误:应用程序未指定android.test.InstrumentationTestRunner检测或未声明uses-library android.test.runner
它也恼人地决定,因为我试图进行一次单元测试,这就是我一直想做的事情.
Jos*_*ger 111
你可能错过了你的节点uses-library和instrumentation节点AndroidManifest.xml:
<manifest ...>
    <application ...>
        <!-- ... -->
        <uses-library android:name="android.test.runner" />
    </application>
    <instrumentation android:name="android.test.InstrumentationTestRunner"
        android:targetPackage="your.package"
        android:label="your tests label" />
</manifest>
小智 59
在Run Configuration您可能拥有的内容中Android JUnit Test,如果其中有任何新的启动配置条目,则将其删除,然后运行它将运行的应用程序.
注意 - 如果您在向Josef添加正确的行之前运行测试用例,这可能是解决方案,如Josef的答案中所述.如果您已完成此操作,请删除配置(将抱怨其标题中未指定任何检测测试运行器),然后再次将其作为Android Junit测试运行,它将创建一个有效的配置,以获取正确的内容已添加到清单中(请参阅Josef的答案).
Cha*_*ins 18
我在本次讨论中注意到的一件事可能是让一些人沮丧,你需要确保清单中的"instrumentation"元素是"manifest"的子元素,而不是"application"的子元素.(这里的例子是正确的,但这很容易混淆.)
http://developer.android.com/guide/topics/manifest/instrumentation-element.html
如果你将你的仪器内容放在应用程序中,它就不会被选中,你在Eclipse ADT插件中选择的仪器运行器可能是空白的.(但不会抛出或显示错误等)
小智 9
只需在eclipse IDE中右键单击您的测试类,然后单击"Run As".选择"运行配置"后,将在eclipse中启动Confiuration窗口,您需要单击"Instrumentation Runner"旁边的单选按钮,然后从下拉列表中选择已配置的Instrumentation Runner.现在单击"应用",然后单击"运行".我想这会解决你的问题.
谢谢,Smruti
| 归档时间: | 
 | 
| 查看次数: | 72969 次 | 
| 最近记录: |