Android, Error = Keine Instrumentierungsinformationen gefunden für: ComponentInfo {}
Es gibt viele Themen / Fragen, die dieses Problem beim Stackoverflow betreffen (z. B. Error = Keine Instrumentierungsinformationen gefunden für: ComponentInfo {}) und andere Website, aber das, was mein Problem anders macht als andere, ist, dass ich an der Automatisierung arbeite. Also lassen Sie mich Ihnen mehr Details geben.
Ich habe kein Problem, wenn ich auf einem lokalen Computer teste (ich meine meinen Laptop). Ich kann Espresso-Tests durchführen und alle Tests bestehen.
Jetzt möchte ich diese Tests auf CI ausführen (in meinem Fall Bitrise). Ich erstelle und starte Emulator. Ich bestätige, dass es dort kein Problem gibt. Ich habe folgendes Skript:
...
# Check which instrumentation packages have been installed on your device, https://stackoverflow.com/a/23394559/513413
echo ""
echo "Check which instrumentation packages have been installed..."
adb shell pm list instrumentation
# Running tests
echo ""
echo "running test..."
adb shell am instrument -w -r -e debug false -e class my.package.name.MyActivityTest my.package.name.test/android.support.test.runner.AndroidJUnitRunner
Dies ist meine Ausgabe von CI:
Check which instrumentation packages have been installed...
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)
running test...
INSTRUMENTATION_STATUS: id=ActivityManagerService
INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{my.package.name.test/android.support.test.runner.AndroidJUnitRunner}
INSTRUMENTATION_STATUS_CODE: -1
android.util.AndroidException: INSTRUMENTATION_FAILED: my.package.name.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)
Ich habe folgende Codezeile indefaultConfig
vonapp.gradle
Datei
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
Ich habeandroid.support.test.runner.AndroidJUnitRunner
unter meiner EditConfiguration, wie Sie im folgenden Link sehen.
Ich schätze, mein Test schlägt fehl, weil ich diesen Befehl nicht im CI-Emulator habe. Meine Frage ist also, wie ich sie über die Befehlszeile hinzufügen kann. Ist das möglich? Vielen Dank
AktualisiereDies ist mein komplettes Skript.
#!/bin/bash
# List of devices attached
adb devices
# List all *.apk files inside /bitrise/deploy path
echo "List of all *.apk files in $BITRISE_DEPLOY_DIR"
cd $BITRISE_DEPLOY_DIR && ls
# Push and Install main apk file
echo ""
echo "Pushing main apk at $BITRISE_APK_PATH to /data/local/tmp/my.package.name and install it..."
adb push $BITRISE_APK_PATH /data/local/tmp/my.package.name
adb shell pm install -r "/data/local/tmp/my.package.name"
# Push and Install Test Unaligned apk file
echo ""
echo "Pushing test unaligned apk at $BITRISE_DEPLOY_DIR/my-app-debug-unaligned.apk to /data/local/tmp/my.package.name.test and install it..."
adb push $BITRISE_DEPLOY_DIR/my-app-debug-unaligned.apk /data/local/tmp/my.package.name.test
adb shell pm install -r "/data/local/tmp/my.package.name.test"
# Check which instrumentation packages have been installed on your device, https://stackoverflow.com/a/23394559/513413
echo ""
echo "Check which instrumentation packages have been installed..."
adb shell pm list instrumentation
# Running tests
echo ""
echo "switch directory to $BITRISE_SOURCE_DIR"
cd $BITRISE_SOURCE_DIR
echo "running test..."
adb shell am instrument -w -r -e debug false -e class my.package.name.path.MinHappyPathTest my.package.name.path/android.support.test.runner.AndroidJUnitRunner