How to split Android Espresso tests into different APKs

笑着哭i 提交于 2019-12-24 06:30:06

问题


I have a Espresso Android test APK with a lot of tests (about 70), and I wanted to split the tests into different APKs and then run them, separately, on Firebase Test Lab. Within the Android Studio framework, I created several Test Suites. However, when I need to generate an APK with fewer tests, I create several copies of the project and I will take tests and generate the APKs with the tests I need.

My question is:

  • Is there any way to split the test APK without always having to do the previous process? That is, are there any mechanisms for generating the APK and specifying which tests (or how many tests) I want to include in my APK?

Many thanks, xptoGirl


回答1:


The easiest way doing this is with gcloud --test-targets. This way you do not have to split up your test APK. Rather you create multiple test runs in Test Lab but with different packages, annotations or classes that you want to test.

E.g. to only run tests in specific sub-packages:

gcloud firebase test android run \
  --app path/to/app.apk \
  --test path/to/tests.apk \
  --device model=walleye,version=26  \
  --test-targets "package com.my.package.tests1","package com.my.package.tests2"


来源:https://stackoverflow.com/questions/58641438/how-to-split-android-espresso-tests-into-different-apks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!