Travis-CI 和 Android JUnit 测试

Travis-CI and Android JUnit Tests

我很难让 Travis-CI 进行 运行 我的单元测试。以下是我的 travis.yml 代码。如果您需要更多信息,请与我们联系!

language: android
jdk: oraclejdk8
sudo: false

android:
  components:
    - platform-tools
    - tools
    - build-tools-24.0.2
    - android-22
    - android-24
    - sys-img-armeabi-v7a-android-22
    - extra-android-m2repository

before_script:
  # Create and start emulator
  - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell input keyevent 82 &

script:
    - ./gradlew connectedAndroidTest

我需要更多信息来了解您的具体问题ci。如果你这样做,我会更新我的答案。

最好的办法是将 link 分享给 public travis-ci 构建、日志或完整的解释。

你的 travis.yml 似乎是正确的,也许你正在尝试 运行 单元测试而不是仪器测试:

script:
    - ./gradlew test

我还会添加一个额外的工具选项,因为 Travis-ci VM 已经过时,您需要 运行 工具和平台工具之间的链来获取最新版本,因为依赖cies:

android:
  components:
    - tools
    - platform-tools
    - tools

验证您的 Espresso configuration if you re trying to run Android Tests and check this guide.