adbshellaminstrument[options]<COMPONENT>

作用:启动对instrument实例的监视。

参数[options]:

-e<key><value>//-e选项需要放在-w选项之前

作用:提供了以键值对形式存在的测试选项。Android中提供了多种键值对,具体参见下表。

举例:-eclasscom.android.phone.FIncomingCallTests#testRejectCall

-r

作用:以原始形式输出测试结果。该选项通常是在性能测试时与-eperftrue一起使用。

参数<COMPONENT>:

-w<test_package_name>/<runner_class>//<test_package_name>和<runner_class>在测试工程的AndroidManifest.xml中查找

作用:保持adbshell打开直至测试完成

举例:-wcom.android.phone.tests/com.android.phone.runners.FunctionalTestRunner

<key><value>参考表

KeyValueDescription

package<Java_package_name>Thefully-qualifiedJavapackagenameforoneofthepackagesinthetestapplication.Anytestcaseclassthatusesthispackagenameisexecuted.NoticethatthisisnotanAndroidpackagename;atestpackagehasasingleAndroidpackagenamebutmayhaveseveralJavapackageswithinit.

class<class_name>Thefully-qualifiedJavaclassnameforoneofthetestcaseclasses.Onlythistestcaseclassisexecuted.

<class_name>#methodnameAfully-qualifiedtestcaseclassname,andoneofitsmethods.Onlythismethodisexecuted.Notethehashmark(#)betweentheclassnameandthemethodname.

functrueRunsalltestclassesthatextendInstrumentationTestCase.

unittrueRunsalltestclassesthatdonotextendeitherInstrumentationTestCaseorPerformanceTestCase.

size[small|medium|large]Runsatestmethodannotatedbysize.Theannotationsare@SmallTest,@MediumTest,and@LargeTest.

perftrueRunsalltestclassesthatimplementPerformanceTestCase.Whenyouusethisoption,alsospecifythe-rflagforaminstrument,sothattheoutputiskeptinrawformatandnotre-formattedastestresults.

debugtrueRunstestsindebugmode.

logtrueLoadsandlogsallspecifiedtests,butdoesnotrunthem.ThetestinformationappearsinSTDOUT.Usethistoverifycombinationsofotherfiltersandtestspecifications.

emmatrueRunsanEMMAcodecoverageanalysisandwritestheoutputto/data//coverage.econthedevice.Tooverridethefilelocation,usethecoverageFilekeythatisdescribedinthefollowingentry.

Note:ThisoptionrequiresanEMMA-instrumentedbuildofthetestapplication,whichyoucangeneratewiththecoveragetarget.

coverageFile<filename>OverridesthedefaultlocationoftheEMMAcoveragefileonthedevice.SpecifythisvalueasapathandfilenameinUNIXformat.Thedefaultfilenameisdescribedintheentryfortheemmakey

adbshellamstart[options]<INTENT>

作用:启动一个activity

举例:adbshellamstart-acom.lt.test.action.SECOND

举例:adbshellamstart-ncom.lt.test/.MyActivity

说明:[options]与<INTENT>参见http://developer.android.com/tools/help/adb.html#am

adbshellamstartservice[options]<INTENT>

作用:启动一个service

举例:adbshellamstartservice-acom.lt.test.action.ONESERVICE

举例:adbshellamstartservice-ncom.lt.test/.MyService

adbshellamforce-stop<PACKAGE>

作用:强制关闭一个应用程序

举例:adbshellamforce-stopcom.lt.test

adbshellambroadcast[options]<INTENT>

作用:发送一个广播

举例:adbshellambroadcast-a"action_finish"(发送一个广播去关闭一个activity)

举例:adbshellambroadcast-aandroid.intent.action.MASTER_CLEAR(恢复出厂设置的方法,会清除内存所有内容)

举例:adbshellambroadcast-ncom.lt.test/.MyBroadcast

adbshellpmlistpackages[options]<INTENT>

作用:列举出所有包含<INTENT>的package

举例:adbshellpmlistpackagescom.lt

说明:[options]与<INTENT>参见http://developer.android.com/tools/help/adb.html#pm

参考链接:

http://developer.android.com/tools/help/adb.html