问题描述
我正在通过 gradle 传递来自 runner 的参数,并在我的 androidTest 中使用它们。
''' 例如:
In build.gradle:
android {
defaultConfig {
testInstrumentationRunnerArguments 'FOO' :'foo'
}
}
In androidTest/foo.java
username= androidx.test.platform.app.InstrumentationRegistry.getArguments().getString("FOO");
测试在本地运行,但在 Firebase TestLab 中运行时,当我尝试使用 key=FOO 访问参数时,出现空指针异常并且测试失败。你能帮我解决这个问题吗。
我不想使用 CLI。如果有什么方法可以使用 android studio 和 firebase testlab web UI 做到这一点,请告诉我。
解决方法
You can pass them in by running tests thru the command line:
使用 --environment-variables
选项。
gcloud firebase test android run \
--type instrumentation \
--app app-debug.apk \
--test app-debug-test.apk \
--environment-variables FOO=foo