2013-01-11 1 views
16

私は簡単なアンドロイドアプリを持っており、私は自分の携帯電話を使ってテストしています。私は、Eclipseを使用してユニットテストケースを実行するとandroid.util.AndroidException:INSTRUMENTATION_FAILED:

、それは私の携帯電話にアプリをインストールします。CLI

問題を使用して日食

  • を使用して

    1. :だから、それを行うには、2つの方法があります実行時にjunit testを実行した後、CLIでcommandを使用すると、 adb -d shell instrument -w com.abc.xyz.test/android.test.InstrumentationTestRunnerが正常に動作します。しかし

      、私は直接、私はエラーを取得しています、最初のEclipseのユニットテストケースを実行せずにCLIで上記のコマンドを実行した場合:

       
      android.util.AndroidException: INSTRUMENTATION_FAILED: com.abc.xyz.test/android.test.InstrumentationTestRunner 
           at com.android.commands.am.Am.runInstrument(Am.java:586) 
           at com.android.commands.am.Am.run(Am.java:117) 
           at com.android.commands.am.Am.main(Am.java:80) 
           at com.android.internal.os.RuntimeInit.finishInit(Native Method) 
           at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:263) 
           at dalvik.system.NativeStart.main(Native Method) 
      INSTRUMENTATION_STATUS: id=ActivityManagerService 
      INSTRUMENTATION_STATUS: Error=Unable to find instrumentation target package: com.abc.xyz 
      INSTRUMENTATION_STATUS_CODE: -1 
      

      AndroidManifest.xmlには含まれています

      android:name="android.test.InstrumentationTestRunner" 
          android:targetPackage="com.abc.xyz" 
      
          inside instrumentation tag 
      

      でした誰も助けてください

  • 答えて

    23

    私はあなたが1月以来それを解決していると思いますが、私はコマンドラインツールで動作し、同様の問題が見つかりました(エラーメッセージはdifferenですt)、それを次のステップで説明するように解決しました。私は空のテストでダミーのプロジェクトを作成してからテストを成功させるまでの全過程を行います。、ステップ

    android create test-project 
        --path MyExampleTest 
        --name MyExampleTest 
        --main ../MyExample 
    

    サード:テストプロジェクトを作成し、

    android create project 
        --name MyExample 
        --target "Google Inc.:Google APIs:17" 
        --path MyExample 
        --package com.example 
        --activity MyExampleActivity 
    

    第二ステップ:プロジェクトを作成し、

    まずステップ:私はそれが誰かのために役立ちます願っていますプロジェクトディレクトリにアクセスしてビルドし、プロセスが正常に終了することを確認してください:

    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) 
    

    第六ステップ、あなたの計装clasesを一覧表示し、現在のプロジェクトが欠落していることを確認します。com.example.tests doesnのための計装、あなたが見ることができるように

    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) 
    

    :私のマシン利回りの

    adb shell pm list instrumentation 
    

    こと存在しないので、私たちはそれを作成しなければなりません。

    第七ステップ、あなたのテストプロジェクトを構築し、それが成功したことを確認してください。

    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 
    

    しかし、同じエラーを避けるためには、計測器クラスを再度作成する必要があります。

    +0

    をアンインストールした後、テストを再インストールするか、キックオフはあなたにBireiありがとう、ありがとう、ありがとう! 私は "Instrumentation Infoを見つけることができませんでした"というエラーが表示されていたので、インストールのアクションで問題が解決しました – gsaslis

    +0

    あなたの方法でチェックしましたが、まったく動作しません。そしてもう一つはもっともっと6番目のステップで私は計測器リストで私のプロジェクトの名前を見ることができますが、テストを実行しようとしているときに上記のようにエラーが出ます。私を助けてください。 –

    +0

    あなたはgradleと似た何かをしましたか? – c3rin

    2

    より正確な説明/アプローチは以下の通りです:

    テストやアプリのディレクトリから両方からあなたが

    adb install -r bin/<>-debug.apk 
    

    を行うことを確認してください。

    その後、ant testはtestsディレクトリから作業する必要があります。 (私の推測では、テストパッケージからアプリケーションに依存しないことがありました。これは失敗を引き起こしていました)。

    上記の小さなハック以外は、私が従う手順の残りはhttp://developer.android.com/のアンドロイドテストの紹介から来ました。

    1

    必ず以前のアプリをアンインストールしてくださいとだけ以前のアプリ