Ответ 1
Я предполагаю, что вы решите его с января, но я работаю с инструментами командной строки, нашел аналогичную проблему (сообщение об ошибке отличается) и решил ее, как я объясняю в следующих шагах. Я делаю весь процесс от создания фиктивного проекта с его пустым тестом до успешного тестового прогона. Я надеюсь, что это может быть полезно для кого-то:
Первый шаг, создайте проект:
android create project
--name MyExample
--target "Google Inc.:Google APIs:17"
--path MyExample
--package com.example
--activity MyExampleActivity
Второй шаг, создайте тестовый проект:
android create test-project
--path MyExampleTest
--name MyExampleTest
--main ../MyExample
Третий шаг, доступ к вашему каталогу проекта, его сбор и проверка успешного завершения процесса:
cd MyExample && ant debug
Четвертый шаг, установите его в эмулятор:
adb -s emulator-5554 install -r bin/MyExample-debug.apk
Пятый шаг, войдите в каталог тестового проекта и попробуйте выполнить тесты:
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)
Шестой шаг, перечислите свои приборы и убедитесь, что ваш текущий проект отсутствует:
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
не существует, поэтому нам нужно его создать.
Седьмой шаг, постройте тестовый проект и убедитесь, что он успешно выполнил:
ant debug
Шаг Eigth, установите его в эмулятор:
adb -s emulator-5554 install -r bin/MyExampleTest-debug.apk
Девятый шаг, перечислите классы инструментов и найдите один из ваших проектов:
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)
Посмотрите на второй, instrumentation:com.example.tests
, который мы хотели.
Десятый шаг, запустите свои тесты:
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
Но вам нужно будет снова создать классы инструментов, чтобы избежать такой же ошибки.