pwittchen / prefser

Wrapper for Android SharedPreferences with object serialization and RxJava Observables
Apache License 2.0
229 stars 26 forks source link

Investigate execution of unit tests on CI server #92

Closed pwittchen closed 8 years ago

pwittchen commented 8 years ago

Unit tests on Travis CI server are not reliable although I'm able to run them locally without problems. They require device emulator on CI. Moreover, I was able to run test coverage with codecov.io once what requires passing tests. Behavior of the unit tests using RxJava on CI server is non-deterministic. Right now, we have problems with PrefserObservablesTest. Initial travis configuration with tests and code coverage is included in .travis.yml.tmp file.

Some tests with observables sometimes throw the following error:

java.util.NoSuchElementException: No event found while waiting for OnNext
    at com.github.pwittchen.prefser.library.utils.RecordingObserver.takeEvent(RecordingObserver.java:61)

Possible fixes: Create custom test runner, set it for tests with RxJava and add additional permissions to Manifest (it was mentioned somewhere inside the issues of RxBinding project). Unfortunately, I don't want to add additional permissions for library, so probably I'll create separate module called testing-utils like in RxBinding project to make it work.

content of initial .travis.yml file

language: android

jdk: oraclejdk8

env:
  global:
    - MALLOC_ARENA_MAX=2
    - ADB_INSTALL_TIMEOUT=10
    - ANDROID_TARGET=android-15
    - ANDROID_ABI=armeabi-v7a

android:
  components:
    - tools
    - platform-tools
    - build-tools-23.0.1
    - android-23
    - extra-android-m2repository
    - extra-google-m2repository
    - sys-img-${ANDROID_ABI}-${ANDROID_TARGET}

install:
  - true

sudo: required

script:
  - ./gradlew clean build check jacocoTestReport assembleAndroidTest
  - echo no | android create avd --force -n test -t $ANDROID_TARGET --abi $ANDROID_ABI
  - emulator -avd test -no-skin -no-audio -no-window &
  - android-wait-for-emulator
  - adb shell setprop dalvik.vm.dexopt-flags v=n,o=v
  - ./gradlew connectedCheck

after_success:
  - bash <(curl -s https://codecov.io/bash)
pwittchen commented 8 years ago

For now it's causing too many problems. It can be subject of investigation and can be re-opened in the future.