Issue
If i am going to run espresso test locally and pass enviroment variable i can do this by adding
defaultConfig {
testInstrumentationRunnerArgument 'USERNAME' 'David'
}
in build.gradle file
then i can call this variable by
InstrumentationRegistry.getArguments().getString("USERNAME")
but when i run this on firebase testlab instrumentationrunner argument are not working
Solution
This is not supported in Test Lab.
If you really need to do this, there's a workaround by overriding the test runner and using the test runner "environment variables" to pass in those key-value pairs.
Override the test runner:
public class MyTestRunner extends AndroidJUnitRunner {
public static String USERNAME;
@Override
public void onCreate(Bundle arguments) {
super.onCreate(arguments);
USERNAME = arguments.getString("USERNAME");
}
}
Use MyTestRunner
in your build.gradle
file:
defaultConfig {
testInstrumentationRunner "com.example.myapp.MyTestRunner"
}
Start your test run in Firebase using the gcloud
command-line app. This is where you pass in your arguments:
gcloud firebase test android run \
--type instrumentation \
--app debug/app-debug.apk \
--test androidTest/debug/app-debug-androidTest.apk \
--environment-variables "USERNAME=david" \
--device model=walleye,version=28
Answered By - Maik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.