2012-11-23 140 views
1

我正在嘗試設置android測試框架。Android命令行測試

我在~/boldapp/BOLDApp/

一個項目,我決定我應該在~/boldapp/BOLDApp/tests必須通過的測試項目,如http://developer.android.com/tools/testing/testing_android.html#TestProjects

描述我做了以下按http://developer.android.com/tools/testing/testing_otheride.html

我跑android create test-project -m ../ -n BOLDAppTest -p tests

我現在想運行生成的儀器測試用例MainActivityTest.java

當運行ant run-tests,所建議的,我得到:

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

當我備選地運行輸出的ant test部分是:

test: 
    [echo] Running tests ... 
    [exec] INSTRUMENTATION_STATUS: id=ActivityManagerService 
    [exec] INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{au.edu.unimelb.boldapp.tests/android.test.InstrumentationTestRunner} 
    [exec] INSTRUMENTATION_STATUS_CODE: -1 
    [exec] android.util.AndroidException: INSTRUMENTATION_FAILED: 

我得到同樣的錯誤,因爲我運行時上述adb shell am instrument -w au.edu.unimelb.boldapp.tests/android.test.InstrumentationTestRunner

以及當我運行時:

adb shell am instrument -w au.edu.unimelb.boldapp/android.test.InstrumentationTestRunner

如何運行測試?

回答

2

你必須。沒有安裝測試apk在你的設備上成功。你可以通過執行adb shell「pm list instrumentation」來檢查。

+0

當我運行adb shell pm列表工具時,我得不到輸出。我沒有意識到我需要一個設備。當我運行「螞蟻艾瑪調試安裝測試」它的作品。 – oadams

+0

恭喜。但是,你知道艾瑪意味着什麼嗎? –