2

我编写了一个简单的 Android 仪器测试用例来测试网络操作。

Test case class name: Main3ActivityTest.java
Method name:addNewEmployee

我使用命令行运行我的测试用例,然后出现以下异常。

Command:
./adb -s emulator-5554 shell am instrument -w -r -e class murali.myapplication.Main3ActivityTest#addNewEmployee murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner

Issue:
INSTRUMENTATION_STATUS: id=ActivityManagerService
    INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner}
    INSTRUMENTATION_STATUS_CODE: -1
    android.util.AndroidException: INSTRUMENTATION_FAILED: murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner
        at com.android.commands.am.Am.runInstrument(Am.java:1093)
        at com.android.commands.am.Am.onRun(Am.java:371)
        at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
        at com.android.commands.am.Am.main(Am.java:100)
        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)

murali.myapplication.Main3ActivityTest在检测列表中找不到我的测试用例 ( ):

$ ./adb -s emulator-5554 shell pm list instrumentation
instrumentation:com.android.emulator.smoketests/android.support.test.runner.AndroidJUnitRunner (target=com.android.emulator.smoketests)
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest)
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)

我已经添加了testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

请帮我找出问题所在?

4

1 回答 1

1

看起来您尚未安装应用程序 - 使用以下方法安装应用程序:

$adb shell pm install -r <directory/apk_name> 

您将能够看到您的仪器正在运行:

$adb shell pm list instrumentation
于 2019-10-14T18:34:31.803 回答