0

我通过 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 做到这一点,请告诉我。

4

1 回答 1

1

您可以通过命令行运行测试来传递它们:

使用该--environment-variables选项。

gcloud firebase test android run \
  --type instrumentation \
  --app app-debug.apk \
  --test app-debug-test.apk \ 
  --environment-variables FOO=foo
于 2021-02-20T02:08:26.180 回答