简体   繁体   中英

Can't do ant run-tests on an Android JUnit project

I am trying to build an AutoTest script that fetches my project from git and then running through the tests in the test project, without having to use any emulator or real device.

I have downloaded the two projects, having them in the same dir and running these commands:

$ android update project -p Labyrinth -n Labyrinth
Updated local.properties
Added file Labyrinth/build.xml
Updated file Labyrinth/proguard-project.txt


$ android update test-project -m ../Labyrinth -p LabyrinthTest/
Resolved location of main project to: /home/me/labyrinth-temp/Labyrinth
Updated project.properties
Updated local.properties
Added file LabyrinthTest/build.xml
Updated file LabyrinthTest/proguard-project.txt
Updated ant.properties
Buildfile: /home/me/labyrinth-temp/LabyrinthTest/build.xml

Then when i go in to the folder LabyrinthTest and trying to run the tests I get this:

$ ant run-tests

BUILD FAILED
Target "run-tests" does not exist in the project "LabyrinthTest". 

Total time: 0 seconds



I have googled and tried everything I can find for the past 3-4 hours without any progress. However, running "ant test" with the emulator works! But I want to run it without it.

$ ant test
Buildfile: /home/me/labyrinth-temp/LabyrinthTest/build.xml

-test-project-check:

test:
 [echo] Running tests ...
 [exec] 
 [exec] com.app.labyrinth.test.BallTest:...
 [exec] Test results for InstrumentationTestRunner=...
 [exec] Time: 0.034
 [exec] 
 [exec] OK (3 tests)
 [exec] 
 [exec] 

BUILD SUCCESSFUL Total time: 1 second

If the information is needed:

Android API version used: 7 (2.1 Eclair)
Android SDK Tools version: 18
Apache Ant(TM) version 1.8.3 compiled on May 17 2012

您没有告诉您模拟器未运行时什么也不起作用,所以我想问题是(假设adb devices显示为联机),您没有在ant命令行中指定序列号 ,如下所示:

$ ant -Dadb.device.arg="-s 0123456789" test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM