How to execute a designated test in Firebase Test Lab

梦想与她 提交于 2019-12-11 17:26:21

问题


I want to run one test from one test suite using gcloud firebase test android run but I can't figure out the syntax.

This command failed:

gcloud firebase test android run \
--type instrumentation \
--project locuslabs-android-sdk \
--app app/build/outputs/apk/debug/app-debug.apk \
--test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
--device model=Pixel2,version=27,locale=en_US,orientation=portrait \
--verbosity debug \
--test-targets "class com.example.firebasetestlabplayground.ExampleInstrumentedTest.test002"

Error message:

java.lang.ClassNotFoundException: com.example.firebasetestlabplayground.ExampleInstrumentedTest.test002
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at android.support.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:72)
at android.support.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:789)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:539)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:382)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.firebasetestlabplayground.ExampleInstrumentedTest.test002" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.example.firebasetestlabplayground.test-F71g9fZiJ95s1aLuzIJRsw==/base.apk", zip file "/data/app/com.example.firebasetestlabplayground-EuQG5YDD3hrz6BPtBz2t6g==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.firebasetestlabplayground.test-F71g9fZiJ95s1aLuzIJRsw==/lib/x86, /data/app/com.example.firebasetestlabplayground-EuQG5YDD3hrz6BPtBz2t6g==/lib/x86, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 8 more

In my research, I came across How to execute a designated test suite class in Firebase Test Lab which was very helpful in getting me this far but it doesn't specify how to run a single test within the suite.

Also, according to https://github.com/piotrmadry/FirebaseTestLab-Android/issues/11, it should be possible to run a single test with the --test-targets parameter, but the documentation doesn't give an example at https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run#--test-targets.


回答1:


After trial and error I discovered that I could specify a single test by using a # instead of a . between the test suite class name and the test name.

This command successfully ran a single test called test002 in com.example.firebasetestlabplayground.ExampleInstrumentedTest:

gcloud firebase test android run \
--type instrumentation \
--project locuslabs-android-sdk \
--app app/build/outputs/apk/debug/app-debug.apk \
--test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk \
--device model=Pixel2,version=27,locale=en_US,orientation=portrait \
--verbosity debug \
--test-targets "class com.example.firebasetestlabplayground.ExampleInstrumentedTest#test002"



回答2:


Michael, that syntax using # is documented in the gcloud command reference (or add --help to your command above to get docs from the command line). That gcloud documentation in turn links to the full documentation for the AndroidJUnitRunner which also describes the full syntax.



来源:https://stackoverflow.com/questions/55759799/how-to-execute-a-designated-test-in-firebase-test-lab

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