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



我有一个android lib项目和一个android测试项目,我已经在eclipse中构建。

现在我正在自动化这个过程,当我试图使用ant运行测试时遇到了一个问题。

当我运行测试项目的"run-tests"目标时,它声称lib项目没有"install target"。

C:Code4MainAndroidMyAppLibTest>ant run-tests
Buildfile: C:Code4MainAndroidMyAppLibTestbuild.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:Code4MainAndroidMyAppLibTest: ../AndroidMyAppLib => C:Code4MainAndroidMyAppLib
    [setup] C:Code4MainAndroidMyAppLibTest: ../AndroidMyAppMocksLib => C:Code4MainAndroidMyAppMocksLib
    [setup] C:Code4MainAndroidMyAppMocksLib: ../AndroidMyAppLib => C:Code4MainAndroidMyAppLib
    [setup] ------------------
    [setup] Ordered libraries:
    [setup] C:Code4MainAndroidMyAppMocksLib
    [setup] C:Code4MainAndroidMyAppLib
    [setup] ------------------
    [setup]
    [setup]
    [setup] Importing rules file: toolsanttest_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: toolsantlib_rules.xml
Duplicated project name in import. Project android_rules defined first in C:eclipseandroid-sdk_r11-windowsandroid-sdk-windowstoolsantmain_rules.xml and again in C:eclipseandroid-sdk_r11-windowsandroid-sdk-windowstoolsantlib_rules.xml
BUILD FAILED
C:eclipseandroid-sdk_r11-windowsandroid-sdk-windowstoolsanttest_rules.xml:51: The following error occurred while executing this line:
Target "install" does not exist in the project "AndroidMyAppLib".

我没有预料到这个库会被安装,(它是一个库而不是apk)但是android_rules试图安装它却失败了。

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

谢谢!

这里有关于如何实现的描述:

http://www.paulbutcher.com/2010/09/android-library-project-with-tests-step-by-step/

相关内容

  • 没有找到相关文章

最新更新