# Run Espresso tests only for Staging

**URL:** <https://discuss.circleci.com/t/run-espresso-tests-only-for-staging/15073>\
**Category:** Mobile\
**Tags:** gradle, circle-yml, android\
**Created:** [August 3, 2017, 3:09pm UTC](https://discuss.circleci.com/t/run-espresso-tests-only-for-staging/15073 "2017-08-03T15:09:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kioli](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kioli/32/16735_2.png) [@kioli](https://discuss.circleci.com/u/kioli)\
**Post date:** [August 3, 2017, 3:09pm UTC](https://discuss.circleci.com/t/run-espresso-tests-only-for-staging/15073/1 "2017-08-03T15:09:42Z")

</div>

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

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [June 18, 2018, 11:33am UTC](https://discuss.circleci.com/t/run-espresso-tests-only-for-staging/15073/2 "2018-06-18T11:33:41Z")

</div>

Closed on June 18, 2018, 11:33am UTC


