CircleCI Build中的自动化测试失败,但有异常

时间:2015-11-03 12:22:27

标签: android android-studio automated-tests robotium circleci

Circle Ci Android Test模拟器脚本始终失败

项目中使用的

circle.yml 文件。

#
#Build configuration for Circle CI
#

general:
artifacts:
    - /home/ubuntu/TestApp/app/build/outputs/apk/

machine:
environment:
    ANDROID_HOME: /usr/local/android-sdk-linux
dependencies:
override:
    - echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-21.1.2,android-21,extra-google-m2repository,extra-google-google_play_services,extra-android-support
     - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies


test:
 override:
    - (./gradlew assemble):
        timeout: 360



test:
 override:
# start the emulator
- emulator -avd circleci-android21 -no-audio -no-window:
    background: true
    parallel: true
# wait for it to have booted
- circle-android wait-for-boot
# run tests  against the emulator.
- ./gradlew connectedAndroidTest
# copy the build outputs to artifacts
- cp -r /home/ubuntu/TestApp/app/build/outputs $CIRCLE_ARTIFACTS
# copy the test results to the test results directory.
- cp -r /home/ubuntu/TestApp/app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORT
CircleCi 中显示

错误消息

   com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:108)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:125)
at com.android.builder.internal.testing.SimpleTestCallable.call(SimpleTestCallable.java:48)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
 Caused by: com.android.ddmlib.InstallException
at com.android.ddmlib.Device.installPackages(Device.java:927)
at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:105)
... 8 more
     Caused by: com.android.ddmlib.ShellCommandUnresponsiveException
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:513)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:390)
at com.android.ddmlib.AdbHelper.executeRemoteCommand(AdbHelper.java:359)
at com.android.ddmlib.Device.executeShellCommand(Device.java:566)
at com.android.ddmlib.Device.createMultiInstallSession(Device.java:987)
at com.android.ddmlib.Device.installPackages(Device.java:884)
... 9 more

如何解决这个问题? 从circle.yml

中删除模拟器测试代码是成功的

1 个答案:

答案 0 :(得分:5)

circle.yml

中试试这个
test:
    override:
    - ADB_INSTALL_TIMEOUT=10 ./gradlew connectedAndroidTest
        timeout: 360

如果它不起作用,请在build.gradle

中添加
com.android.ddmlib.DdmPreferences.setTimeOut(600000)

如果它仍然不起作用,请在adbOptions中添加build.gradle

android {
    adbOptions {
        timeOutInMs 600000
    }
}

另见this repo。我不得不做所有3,它在那里工作。