Adibe7
Adibe7

Reputation: 3539

How to run unittests of an android lib using ant?

I have an android lib project, and an android test project i've built in eclipse.

Now i'm automating the process and i encounterred a problem when trying to run the tests using ant.

When i run the "run-tests" target of the test project, It claims the lib project does not have "install target".

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".

I didn't expect the lib to be installed, (it's a lib not an apk) but the android_rules tries to intall it and fails.

Do i need to configure something special for test targets that test libs and not apps?

Thanks!

Upvotes: 3

Views: 2392

Answers (1)

Paul Butcher
Paul Butcher

Reputation: 10852

There's a description of how to achieve this here:

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

Upvotes: 3

Related Questions