Android的,错误=无法找到仪器仪表信息:ComponentInfo {} [英] Android, Error=Unable to find instrumentation info for: ComponentInfo {}
问题描述
有很多话题/问题都把计算器这个问题(如错误=无法找到仪器仪表信息为:{ComponentInfo } )等网站,但使我的问题比其他人不同的是,我自动化工作的事情。所以让我给你更多的细节。
我有,当我在本地机器上测试没有问题(我的意思是我的笔记本电脑)。我可以运行长者preSSO测试和所有测试通过。
现在,我想(在我的情况Bitrise)运行CI这些测试。我创建和运行仿真器。我确认没有问题存在。我有以下脚本:
...
#检查该仪器包已安装设备,http://stackoverflow.com/a/23394559/513413上
回声
回声检查已经安装了哪些仪器包......
亚行外壳下午名单仪表#运行测试
回声
回声运行试验......
亚行外壳上午仪器-w -r -e调试假-e类my.package.name.MyActivityTest my.package.name.test / android.support.test.runner.AndroidJUnitRunner
这是从我的CI输出:
检查哪些仪器软件包安装...
仪器仪表:com.android.emulator.smoketests / android.support.test.runner.AndroidJUnitRunner(目标= com.android.emulator.smoketests)
仪器仪表:com.android.smoketest.tests / com.android.smoketest.SmokeTestRunner(目标= com.android.smoketest)
仪器仪表:com.example.android.apis / .app.LocalSampleInstrumentation(目标= com.example.android.apis)
运行测试...
INSTRUMENTATION_STATUS:ID = ActivityManagerService
INSTRUMENTATION_STATUS:错误=无法找到仪器仪表信息: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
在com.android.commands.am.Am.runInstrument(Am.java:1093)
在com.android.commands.am.Am.onRun(Am.java:371)
在com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
在com.android.commands.am.Am.main(Am.java:100)
在com.android.internal.os.RuntimeInit.nativeFinishInit(本机方法)
在com.android.internal.os.RuntimeInit.main(RuntimeInit.java:251)
我有以下code的行 defaultConfig
app.gradle
文件:
testInstrumentationRunner'android.support.test.runner.AndroidJUnitRunner
我 android.support.test.runner.AndroidJUnitRunner
我EditConfiguration下,你在下面的链接查看。
我猜是因为我没有在我的CI的模拟器这个命令做我的测试失败。所以我的问题是我如何可以通过命令行来添加呢?那可能吗?谢谢你。
更新
这是我的全部脚本。
#!/斌/庆典设备#名单附后
ADB设备#列出所有*的apk文件里面/ bitrise /部署路径
回声在$ BITRISE_DEPLOY_DIR所有*的apk文件列表
CD $ BITRISE_DEPLOY_DIR&放大器;&安培; LS#推送并安装主要的apk文件
回声
回声在$ BITRISE_APK_PATH主推以APK和/data/local/tmp/my.package.name安装它......
亚行推$ BITRISE_APK_PATH /data/local/tmp/my.package.name
亚行外壳安装时-r/data/local/tmp/my.package.name#推送并安装测试未对齐的apk文件
回声
回声在$ BITRISE_DEPLOY_DIR推进测试不对齐的apk /我-APP-调试unaligned.apk到/data/local/tmp/my.package.name.test并安装它......
亚行推$ BITRISE_DEPLOY_DIR /我-APP-调试unaligned.apk /data/local/tmp/my.package.name.test
亚行外壳安装时-r/data/local/tmp/my.package.name.test#检查该仪器包已安装设备,http://stackoverflow.com/a/23394559/513413上
回声
回声检查已经安装了哪些仪器包......
亚行外壳下午名单仪表#运行测试
回声
回声开关目录$ BITRISE_SOURCE_DIR
CD $ BITRISE_SOURCE_DIR
回声运行试验......
亚行外壳上午仪器-w -r -e调试假-e类my.package.name.path.MinHappyPathTest my.package.name.path / android.support.test.runner.AndroidJUnitRunner
您必须安装运行亚行外壳上午仪之前(ADB安装)和应用程序APK和测试APK(这是不同的APK)。
There are a lot of topics/questions regard this issue on stackoverflow (such as Error=Unable to find instrumentation info for: ComponentInfo{ }) and other website but the thing that make my problem different than others is I am working on automation. So let me give you more details.
I have no problem when I'm testing on local machine (I mean my laptop). I can run Espresso testing and all tests passes.
Now, I want to run these tests on CI (Bitrise in my case). I create and run Emulator. I confirm there is no issue there. I have following script:
...
# Check which instrumentation packages have been installed on your device, http://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
This is my output from 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)
I have following line of code in defaultConfig
of app.gradle
file:
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
I have android.support.test.runner.AndroidJUnitRunner
under my EditConfiguration as you see in the following link.
I guess my test fails because I don't have this command in my CI's emulator. So my question is how I can add it via command line? Is that possible? Thanks.
Update
This is my full script.
#!/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, http://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
You must install (adb install) and application APK and test APK (this is different APK) before running "adb shell am instrument".
这篇关于Android的,错误=无法找到仪器仪表信息:ComponentInfo {}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!