1月以降は解決されていると思いますが、コマンドラインツールを使用して同様の問題(エラーメッセージは異なります)を見つけ、次の手順で説明するように解決しました。空のテストを含むダミー プロジェクトの作成から、テストの実行が成功するまでのプロセス全体を行います。誰かに役立つことを願っています:
最初のステップで、プロジェクトを作成します。
android create project
--name MyExample
--target "Google Inc.:Google APIs:17"
--path MyExample
--package com.example
--activity MyExampleActivity
2 番目のステップで、テスト プロジェクトを作成します。
android create test-project
--path MyExampleTest
--name MyExampleTest
--main ../MyExample
3 番目のステップでは、プロジェクト ディレクトリにアクセスしてビルドし、プロセスが正常に終了することを確認します。
cd MyExample && ant debug
ステップ 4で、エミュレーターにインストールします。
adb -s emulator-5554 install -r bin/MyExample-debug.apk
5 番目のステップでは、テスト プロジェクト ディレクトリにアクセスし、テストを実行してみます。
cd ../MyExampleTest &&
adb shell am instrument -w com.example.tests/android.test.InstrumentationTestRunner
これにより、次の結果が得られます。
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{com.example.tests/android.test.InstrumentationTestRunner}
INSTRUMENTATION_STATUS_CODE: -1
android.util.AndroidException: INSTRUMENTATION_FAILED: com.example.tests/android.test.InstrumentationTestRunner
at com.android.commands.am.Am.runInstrument(Am.java:676)
at com.android.commands.am.Am.run(Am.java:119)
at com.android.commands.am.Am.main(Am.java:82)
at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:235)
at dalvik.system.NativeStart.main(Native Method)
ステップ 6で、インストルメンテーション クラスを一覧表示し、現在のプロジェクトが欠落していることを確認します。
adb shell pm list instrumentation
私のマシンでは、次のようになります。
instrumentation:com.android.emulator.connectivity.test/android.test.InstrumentationTestRunner (target=com.android.emulator.connectivity.test)
instrumentation:com.android.emulator.gps.test/android.test.InstrumentationTestRunner (target=com.android.emulator.gps.test)
instrumentation:com.android.example.spinner.tests/android.test.InstrumentationTestRunner (target=com.android.example.spinner)
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest)
instrumentation:com.android.smoketest.tests/android.test.InstrumentationTestRunner (target=com.android.smoketest)
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)
ご覧のとおり、 のインストルメンテーションcom.example.tests
は存在しないため、作成する必要があります。
7 番目のステップでは、テスト プロジェクトをビルドし、正常に実行されたことを確認します。
ant debug
ステップ 8で、エミュレータにインストールします。
adb -s emulator-5554 install -r bin/MyExampleTest-debug.apk
ステップ 9では、インストルメンテーション クラスを一覧表示し、プロジェクトの 1 つを探します。
adb shell pm list instrumentation
これにより、次の結果が得られます。
instrumentation:com.android.emulator.connectivity.test/android.test.InstrumentationTestRunner (target=com.android.emulator.connectivity.test)
instrumentation:com.android.emulator.gps.test/android.test.InstrumentationTestRunner (target=com.android.emulator.gps.test)
instrumentation:com.android.example.spinner.tests/android.test.InstrumentationTestRunner (target=com.android.example.spinner)
instrumentation:com.android.smoketest.tests/com.android.smoketest.SmokeTestRunner (target=com.android.smoketest)
instrumentation:com.android.smoketest.tests/android.test.InstrumentationTestRunner (target=com.android.smoketest)
instrumentation:com.example.tests/android.test.InstrumentationTestRunner (target=com.example)
instrumentation:com.example.android.apis/.app.LocalSampleInstrumentation (target=com.example.android.apis)
最後から 2 番目を見てください、instrumentation:com.example.tests
それは私たちが望んでいたものです。
10 番目のステップで、テストを実行します。
adb shell am instrument -w com.example.tests/android.test.InstrumentationTestRunner
これにより、次の結果が得られます。
Test results for InstrumentationTestRunner=
Time: 0.0
OK (0 tests)
それだけです。テストを実装し、通常どおりコンパイルしてインストールします。さらに、次のように削除できます。
adb shell pm uninstall com.example.tests
ただし、同じエラーを回避するには、インストルメンテーション クラスを再度作成する必要があります。