Tests failing in TestLab, but passing in local when Passing arguments from runner from gradle and using them in my androidTest

415 views Asked by At

I am passing arguments from runner through gradle and using them in my androidTest.

''' e;g:

In build.gradle:    
android {
          defaultConfig {
                testInstrumentationRunnerArguments 'FOO' :'foo'
           }
       }

 In androidTest/foo.java
     username= androidx.test.platform.app.InstrumentationRegistry.getArguments().getString("FOO");

The test is working locally, but when running in Firebase TestLab, I am getting a null pointer exception and tests failing when I am trying to access argument with key=FOO. Can you please help me with this issue.

I do not want to use CLI. If there is a way I can do this using android studio and firebase testlab web UI, please let me know.

1

There are 1 answers

4
yogurtearl On

You can pass them in by running tests thru the command line:

Use the --environment-variables option.

gcloud firebase test android run \
  --type instrumentation \
  --app app-debug.apk \
  --test app-debug-test.apk \ 
  --environment-variables FOO=foo