使用自定义InstrumentationTestRunner在Eclipse中导致错误 [英] Using custom InstrumentationTestRunner in Eclipse causes Error

查看:872
本文介绍了使用自定义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:

[测试项目]未正确配置运行测试: 在它的Andr​​oidManifest.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?

推荐答案

在你的Andr​​oidManifest.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.

这篇关于使用自定义InstrumentationTestRunner在Eclipse中导致错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆