Run Espresso tests only for Staging

android
gradle
circle.yml

#1

I’ve the need to test some fragments with Espresso, so I needed to create a fake Activity to launch them on and I did so in the folder ‘staging’. not to pollute with test code the official release

This though put me in the position of failing my CI if I use the command
./gradlew connectedAndroidTest -PdisablePreDex

If I do not use that command but the more specific
./gradlew connectedProductionDebugAndroidTest -PdisablePreDex
I keep getting the error

./gradlew connectedStagingDebugAndroidTest -PdisablePreDex died unexpectedly

do you have any suggestion?

p.s. I attach my whole circle.yml here

machine:
    java:
    #Because buildtools 24.0.2 and above require Java 1.8 or above
    version: oraclejdk8
  environment:
    #Necessary for the Android SDKs to function properly. Also useful for booting up the emulator in later steps
    ANDROID_HOME: /home/ubuntu/android
    GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
    TEST_FLAGS: "--configure-on-demand -PdisablePreDex"
    ADB_INSTALL_TIMEOUT: "10"

#Install android build tools, platforms (upported versions here https://circleci.com/docs/android)
dependencies:
  pre:
    - chmod +x gradlew
    - ./gradlew --foreground:
        background: true
    - until (./gradlew --status | grep -q IDLE); do echo "Waiting for Gradle daemon..."; done
  cache_directories:
    - ~/.android
    - ~/android
  override:
    - (source scripts/environmentSetup.sh && getAndroidSDK) #wat?

#Pull any submodules
checkout:
  post:
    - git submodule init
    - git submodule update
    - cp local.properties.ci local.properties

#-PdisablePreDex is a must else gradle just dies due to memory limit
test:
  override:
    - ./gradlew assembleDebug -PdisablePreDex
    - emulator -avd circleci-android24 -no-audio -no-window:
        background: true
        parallel: true
    # wait for it to have booted
    - circle-android wait-for-boot
    # unlock the emulator screen
    - sleep 30
    - adb shell input keyevent 82
    # run tests  against the emulator.
    - ./gradlew connectedProductionDebugAndroidTest -PdisablePreDex
    # copy the build outputs to artifacts
    - cp -r app/build/outputs $CIRCLE_ARTIFACTS
    # copy the test results to the test results directory.
    - cp -r app/build/outputs/androidTest-results/* $CIRCLE_TEST_REPORTS

#2