使用自定义InstrumentationTestRunner在Eclipse中导致错误
我有一个单独的测试项目在Eclipse中已成功运行了两个命令行和Eclipse在一段时间。在使用詹金斯运行测试中,我碰到的地方标准InstrumentationTestRunner不输出在詹金斯支持XML格式的问题。我读过在互联网上使用自定义InstrumentationTestRunner。这适用于使用ADB命令行,但由于Android测试用例运行失败时在Eclipse。
I have a seperate Test Project in Eclipse that has been running successfully for a while in both command line and Eclipse. While using Jenkins to run my tests, I've run into the issue where the standard InstrumentationTestRunner does not output in a Jenkins supported xml format. I've read on the internet to use a custom InstrumentationTestRunner. This works in the command line using ADB, but fails in Eclipse when running as Android Test Case.
我已经下载了一个自定义的仪器测试运行(com.neenbedankt.android.test),并把它添加到AndroidManifest是这样的:
I've downloaded a custom instrumentation test runner (com.neenbedankt.android.test) and added it to the AndroidManifest like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.testedapplication.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" />
<instrumentation
android:name="com.neenbedankt.android.test.InstrumentationTestRunner"
android:targetPackage="com.testedapplication" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
</manifest>
下面是我得到在Eclipse中的错误:
Here is the error that I get in Eclipse:
[测试项目]未正确配置运行测试: 在它的AndroidManifest.xml仪器android.test.InstrumentationTestRunner一个targetPackage属性找不到!
[Test Project] is not configured correctly for running tests: A targetPackage attribute for instrumentation android.test.InstrumentationTestRunner in its AndroidManifest.xml could not be found!
您可以看到,我已经设置targetPackage在那里,所以我不知道我还能做什么?
You can see that i've set the targetPackage there, so I'm not sure what else I can do?
在你的AndroidManifest.xml中添加这两种仪器。
Add both instrumentation in your AndroidManifest.xml.
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.example.myapp" />
<instrumentation
android:name=".MyRunner"
android:targetPackage="com.example.myapp" />
然后去包资源管理器 - > $(您的测试Prject $) - >运行方式 - >运行配置 - > Android的JUnit测试 - > $(测试项目) - >仪表亚军,并选择你的亚军那里。
Then go to Package explorer --> $(Your Test Prject$) --> Run As --> Run configurations --> Android JUnit Test --> $(Your Test Project) --> Instrumentation Runner and select your runner there.