我一直在阅读帖子,最终生成了一个*.yaml
文件,它能够正常工作,但是似乎需要的时间太长了。我已经使用了5或6个左右的测试,在本地需要4秒才能通过,但当我启动流水线时,需要约12分钟。我想知道是否我忽略了缓存方面的某些东西,或者我可以使它更快。
注:我也运行应用程序中一个功能的UI测试,认为这比运行应用程序的所有Instrumental tests
要快。
我正在使用以下bash命令:
- 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: Cache@2
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()
有什么可以并行处理以加快管道速度的方法吗?
_注意:在使用macos-latest
时,会出现一个警告:
是否有办法在Ubuntu上运行它以避免此警告?我已经尝试过了,但是它会崩溃并出现以下错误:
有时,第一次成功运行后,它可以正常工作,但是当尝试不更改任何代码再次运行时会随机崩溃。可能与yml的配置有关吗?关于缓存或其他什么东西?很奇怪,因为所有测试都失败了,而不仅仅是一个或两个(可能是一个 flaky 的测试,但看起来不像...)
还有当我运行命令./gradlew:features-login:connectedAndroidTest --console=plain --stacktrace
时,它会编译整个项目,我以为如果只编译我的feature,则只会编译我的feature而不是整个项目。
$ANDROID_HOME/tools/bin/sdkmanager
已经被弃用。它对你还有用吗? - Ilya Gazman