Explorar o código

Run sample instrumented unit test in Travis

David A. Velasco %!s(int64=8) %!d(string=hai) anos
pai
achega
2cfcb2318c
Modificáronse 3 ficheiros con 40 adicións e 10 borrados
  1. 21 6
      .travis.yml
  2. 0 4
      build.gradle
  3. 19 0
      wait_for_emulator.sh

+ 21 - 6
.travis.yml

@@ -2,17 +2,32 @@ sudo: false
 language: android
 android:
   components:
+  - platform-tools
+  - tools
   - build-tools-23.0.3
   - android-23
-  - android-22
-  - android-19
+  - extra-android-m2repository
+  - sys-img-armeabi-v7a-android-23
+before_install:
+  - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI -c 20M
+  - emulator -avd test -no-skin -no-audio -no-window &
+  - chmod +x ./wait_for_emulator.sh
+  - ./wait_for_emulator.sh
 script:
-  - ./setup_env.sh ant
-  - ant clean
-  - ant debug
-#  - ./gradlew connectedAndroidTest
+# build app and assemble APK, in debug mode
+  - ./gradlew assembleDebug
+# run all the local unit tests
+  - ./gradlew testDebug
+# - ./gradlew connectedAndroidTest
+# install app, then assemble and install instrumented tests
+  - ./gradlew installDebug
+  - ./gradlew installDebugAndroidTest
+# run sample instrumented unit test
+  - adb shell am instrument -w -e debug false -e class com.owncloud.android.datamodel.OCFileUnitTest com.owncloud.android.test/android.support.test.runner.AndroidJUnitRunner
 env:
   global:
   - secure: bm8mkBKaujxI/C7Kp2NjwDl0vsfWd3qDGZ+7WiLPGTbXnwJf8urxFQLrMkhqIR4wZs2M1LSW+P9SfD2FwL5Y0GDo29IeYLqhW5LIT8tGCZevBUfMDqd4w+eFHY73FXEAwLWVavfKmeuyisK/JNwGr75penOuQkZXTow6wgNLBjs=
   - secure: EqLPMLaAcr+6NKeXWJdaUiNfMHJ+zdocKw7SyWsezKMMfsY6hME22m8TNHJZpt0nPCDoX7iPjJoh8svOe2RZo6UZG2q4hjcLxBu29b7QvJeChq7oJvjXPVNRUg2P2zJ2OUBbnyOhpw3cZruIncSr+QasSD8FGI7j3kw3t/86YE0=
   - secure: pfNH4RVBy0vRPKRY3z4EQD9SRPyCuqYISQ+87cOlfpVbYHOc7xspaQSg7L9sB/sBMumOuMgGSLD6RincRrSy6nHhd70Vm4ccJxJYOynqDxC3EXNihDesw9Q+MJh1mr7WpTP21sXpP4+HkLQV0U+bKl3xcnGgeR4FU3BWYigNMkA=
+  matrix:
+  - ANDROID_TARGET=android-23 ANDROID_ABI=armeabi-v7a

+ 0 - 4
build.gradle

@@ -66,10 +66,6 @@ android {
     defaultConfig {
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
 
-        buildConfigField "String", "TEST_USER", "${TEST_USER}"
-        buildConfigField "String", "TEST_PASSWORD", "${TEST_PASSWORD}"
-        buildConfigField "String", "TEST_SERVER_URL", "${TEST_SERVER_URL}"
-
         testInstrumentationRunnerArguments TEST_USER: "${TEST_USER}"
         testInstrumentationRunnerArguments TEST_PASSWORD: "${TEST_PASSWORD}"
         testInstrumentationRunnerArguments TEST_SERVER_URL: "${TEST_SERVER_URL}"

+ 19 - 0
wait_for_emulator.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+bootanim=""
+failcounter=0
+checkcounter=0
+until [[ "$bootanim" =~ "stopped" ]]; do
+   bootanim=`adb -e shell getprop init.svc.bootanim 2>&1`
+   echo "($checkcounter) $bootanim"
+   if [[ "$bootanim" =~ "not found" ]]; then
+      let "failcounter += 1"
+      if [[ $failcounter -gt 30 ]]; then
+        echo "Failed to start emulator"
+        exit 1
+      fi
+   fi
+   let "checkcounter += 1"
+   sleep 10
+done
+echo "Done"