如何使用ant运行android库的单元测试?

时间:2011-07-03 16:32:52

标签: android unit-testing ant automated-tests

我有一个android lib项目,以及我在eclipse中构建的一个android测试项目。

现在我正在自动化该过程,并且在尝试使用ant运行测试时遇到了问题。

当我运行测试项目的“运行测试”目标时,它声称lib项目没有“安装目标”。

C:\Code4\Main\AndroidMyAppLibTest>ant run-tests
Buildfile: C:\Code4\Main\AndroidMyAppLibTest\build.xml
    [setup] Android SDK Tools Revision 11
    [setup] Project Target: Android 2.3.3
    [setup] API level: 10
    [setup]
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] C:\Code4\Main\AndroidMyAppLibTest: ../AndroidMyAppLib => C:\Code4\Main\AndroidMyAppLib
    [setup] C:\Code4\Main\AndroidMyAppLibTest: ../AndroidMyAppMocksLib => C:\Code4\Main\AndroidMyAppMocksLib
    [setup] C:\Code4\Main\AndroidMyAppMocksLib: ../AndroidMyAppLib => C:\Code4\Main\AndroidMyAppLib
    [setup] ------------------
    [setup] Ordered libraries:
    [setup] C:\Code4\Main\AndroidMyAppMocksLib
    [setup] C:\Code4\Main\AndroidMyAppLib
    [setup] ------------------
    [setup]
    [setup]
    [setup] Importing rules file: tools\ant\test_rules.xml

-install-tested-project:
    [setup] Android SDK Tools Revision 11
    [setup] Project Target: Android 2.3.3
    [setup] API level: 10
    [setup] Project Type: Android Library
    [setup]
    [setup] ------------------
    [setup] Resolving library dependencies:
    [setup] No library dependencies.
    [setup]
    [setup] ------------------
    [setup]
    [setup] WARNING: No minSdkVersion value set. Application will install on all Android versions.
    [setup]
    [setup] Importing rules file: tools\ant\lib_rules.xml
Duplicated project name in import. Project android_rules defined first in C:\eclipse\android-sdk_r11-windows\android-sdk-windows\tools\ant\main_rules.xml and again in C:\eclipse\android-sdk_r11-windows\android-sdk-windows\tools\ant\lib_rules.xml

BUILD FAILED
C:\eclipse\android-sdk_r11-windows\android-sdk-windows\tools\ant\test_rules.xml:51: The following error occurred while executing this line:
Target "install" does not exist in the project "AndroidMyAppLib".

我没想到要安装lib,(它是lib而不是apk)但是android_rules试图安装它并失败。

我是否需要为测试目标而不是应用程序的测试目标配置一些特殊的东西?

谢谢!

1 个答案:

答案 0 :(得分:3)