eclipse調試Cts 單項,eclipse調試cts

來源:互聯網
上載者:User

eclipse調試Cts 單項,eclipse調試cts

        Cts測試中,單項失敗是常用的事情,想要尋找原因卻比較麻煩,因為cts的command line 雖然提供了單項單獨測試的方法,卻只會輸出結果,最多也就保留了device和host的log,用eclipse來調試還是比較不常見的。今天想到了這個麻煩,研究了下eclipse 調試Cts單項的方法:

        首先,Cts的測試主要還是要依賴apk,所以它的調試還是和app的調試很類似的。

1. 通過Cts command line 單獨測試一下失敗項,從log給出的資訊中找到對應的apk。

2. Install這個apk,想辦法讓它跑起來,如果有activity,那am start 就好了。

3. 如果沒有activity 只有instrumentation,那就要用am instrument,這個命令不太常用


am instrument: start an Instrumentation.  Typically this target <COMPONENT>  is the form <TEST_PACKAGE>/<RUNNER_CLASS>.  Options are:    -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT).  Use with        [-e perf true] to generate raw output for performance measurements.    -e <NAME> <VALUE>: set argument <NAME> to <VALUE>.  For test runners a        common form is [-e <testrunner_flag> <value>[,<value>...]].    -p <FILE>: write profiling data to <FILE>    -w: wait for instrumentation to finish before returning.  Required for        test runners.    --user <USER_ID> | current: Specify user instrumentation runs in;        current user if not specified.    --no-window-animation: turn off window animations while running.    --abi <ABI>: Launch the instrumented process with the selected ABI.        This assumes that the process supports the selected ABI.


說明不是很清楚,大概可以看出可以通過 am instrument -r -w XXX 一個instrumentation的名字來跑這個instrumentation。

如何跑單項呢? 要用到-e 

例如:

am instrument -r -e class android.provider.cts.MediaStore_FilesTest#testAccess -w com.android.cts.provider/android.support.test.runner.AndroidJUnitRunner


android.provider.cts.MediaStore_FilesTest#testAccess 這一串是不是很熟悉呢,對了,就是cts單項測試時候列印出來的東東,包名類名加方法名。

com.android.cts.provider/android.support.test.runner.AndroidJUnitRunner 這一串呢就是instrumentation的名字,咋知道呢?AndroidManifest裡有。

通過pm list instrumentation 也可以查出來。


ok,只要能讓這個apk跑起來就好辦了,eclipse就可以attach來調試咯。

找個時機去attach也是關鍵,這裡就可以用am set-debug-app來創造時機了。這是一個很有內涵的命令,找個時間再來分析了。


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.