Monday, 28 June 2021

How to run Espresso UI tests in Azure devops pipeline

I've been reading posts and I ended up with a *.yaml that works but looks like is taking way too long because I've tried it with more or less 5 or 6 tests, locally it needs 4 seconds to pass and when I launch the pipeline it takes ~12 min and I'd like to know if I missing something about caching, or I could make it faster.

Note: That I'm also running the UI tests of one feature of the app, thinking this is faster than if I run all the Instrumental tests of the app I'm using this bash to do so :

  • bash: | ./gradlew :features-login:connectedAndroidTest --console=plain --stacktrace ./gradlew --stop
trigger:
  - develop

pool:
  vmImage: 'macos-latest'

jobs:
  - job: Phase_1
    timeoutInMinutes: 25
    displayName: Run Instrumented Tests and publish results
    condition: succeeded()
    pool:
      vmImage: 'macos-latest'
    steps:
      - task: CacheBeta@0
        displayName: 'Caching System Images for AVD'
        inputs:
          key: 'AVD_IMAGES_PIXEL_28'
          path: '$(ANDROID_HOME)/system-images'
          cacheHitVar: 'AVD_IMAGES_RESTORED'
        continueOnError: true
        condition: succeededOrFailed()
      - bash: |
          echo "y" | $ANDROID_HOME/tools/bin/sdkmanager --install 'system-images;android-28;google_apis;x86'
        displayName: 'Download and install emulator image'
        condition: ne(variables.AVD_IMAGES_RESTORED, 'true')
      - bash: |
          echo "no" | $ANDROID_HOME/tools/bin/avdmanager create avd -n android_emulator -k 'system-images;android-28;google_apis;x86' -d 17 --force
          echo "Emulator created successfully $(ANDROID_HOME/emulator/emulator -list-avds), launching it"
          nohup $ANDROID_HOME/emulator/emulator -avd android_emulator -skin 1080x1920 -no-snapshot -no-audio -no-boot-anim -accel auto -gpu auto -qemu -lcd-density 420 > /dev/null 2>&1 &
          $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do sleep 1; done'
          $ANDROID_HOME/platform-tools/adb devices
          echo "Emulator started"
        displayName: 'Create and start emulator'
      - bash: |
          ./gradlew :features-login:connectedAndroidTest --console=plain  --stacktrace
          ./gradlew --stop
        displayName: 'Run Instrumented Tests'
        continueOnError: true
      - task: PublishTestResults@2
        displayName: 'Publish Test Results'
        inputs:
          testResultsFiles: '**/outputs/androidTest-results/**/TEST*.xml'
          failTaskOnFailedTests: true
          testRunTitle: 'Test results'
        condition: succeededOrFailed()

Is something I could do in parallel to make the pipeline faster?



from How to run Espresso UI tests in Azure devops pipeline

No comments:

Post a Comment