Firebase Remote Config and Test Lab

2a37bf1e025cc1523124774c760df91a?s=47 Rebecca Franks
September 26, 2016

Firebase Remote Config and Test Lab

This presentation was given at Google Developer Launchpad in Nairobi on the 26 September 2016. It covers using Firebase remote config in your project with AB testing, staged rollout of features and using test lab in your projects.

2a37bf1e025cc1523124774c760df91a?s=128

Rebecca Franks

September 26, 2016
Tweet

Transcript

  1. #LaunchpadDev Remote Config & Test Lab Rebecca Franks Google Developer

    Expert - Android / Senior Android Developer @ DVT @riggaroo riggaroo.co.za
  2. Agenda • Remote Config • Setup & Basic Usage •

    Conditions • A/B Testing • Staged Rollouts • Test Lab • Robo Tests • Instrumentation Tests
  3. Remote Config #LaunchpadDev

  4. • Key / Value Pairs saved on Firebase server •

    Change behaviour at runtime • No app update required Remote Config
  5. Features • Quickly deploy changes • Customise your app for

    segments of user base • Run A/B Tests • Free!
  6. Available for Android iOS

  7. Firebase Server Setup

  8. Android Setup Project Level build.gradle: buildscript { // ... dependencies

    { // ... classpath 'com.google.gms:google-services:3.0.0' } }
  9. Android Setup App Level app/build.gradle: dependencies { // ... compile

    'com.google.firebase:firebase-core:9.4.0' compile 'com.google.firebase:firebase-config:9.4.0' } // At the bottom apply plugin: 'com.google.gms.google-services'
  10. Android Setup • Download google-services.json • Place in app/ folder.

    • Create remote config defaults file - res/xml/ remote_config.xml <?xml version="1.0" encoding="utf-8"?> <defaultsMap> <entry> <key>welcome_message</key> <value>Hello User!</value> </entry> </defaultsMap>
  11. Initialise Firebase Remote Config remoteConfig = FirebaseRemoteConfig.getInstance(); FirebaseRemoteConfigSettings config =

    new FirebaseRemoteConfigSettings.Builder() .setDeveloperModeEnabled(BuildConfig.DEBUG) .build(); remoteConfig.setConfigSettings(config); remoteConfig.setDefaults(R.xml.remote_config);
  12. Fetch remoteConfig.fetch(CACHE_TIME_SECONDS).addOnComplete Listener(new OnCompleteListener<Void>() { }); @Override public void onComplete(@NonNull

    Task<Void> task) { if (task.isSuccessful()) { Log.d(TAG, "Fetch Succeeded"); remoteConfig.activateFetched(); } else { Log.d(TAG, "Fetch Failed"); } displayWelcomeMessage(); }
  13. Display void displayWelcomeMessage(){ String helloMessage = remoteConfig.getString("welcome_message"); greetingTextView.setText(helloMessage); }

  14. Demo Android app fetching single remote config value

  15. Types you can store on Remote Config • Strings •

    Integers • Booleans • Long • Double • Byte Arrays
  16. Conditions • Powerful decision- making server • Target a group

    of app instances • Made up of one or more rules that must evaluate to true
  17. Different greeting per platform?

  18. Demo - No code changes!

  19. Types of Conditionals • OS Type • App ID •

    Device in Region or Country • App Version • Language • Audience from Analytics • Random Percentile Priority? Can be reordered on “Conditions” tab.
  20. A/B Testing & Feature Rollout • Experimenting with your UI

    • Different audiences receive different UI
  21. A/B Testing - Server Setup

  22. A/B Testing - Android Setup String experiment = config.getString("experiment_variant"); FirebaseAnalytics.getInstance(this)

    .setUserProperty("Experiment", experiment); if (experiment.equals("variant_a")) { //.. } else if (experiment.equals("variant_b")) { //... } else { //.. }
  23. Demo A B No Experiment

  24. Analytics Log your events + track in the Firebase Console

    buttonCheckout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { //.. } }); firebaseAnalytics.logEvent(“CheckoutClicked”, new Bundle());
  25. A/B Testing - Analytics

  26. Filter - Variant_A

  27. Experiment A - Winner! A

  28. Gradual Feature Rollouts • Leverage “User in Random Percentile” feature

    • Gradually increase the value of the percentage • Rollout to more customers as you gain confidence
  29. Create stage rollout condition

  30. Create config using that condition

  31. Gradually increase value

  32. Test Lab #LaunchpadDev

  33. What is Firebase Test Lab? • Run tests at Googles

    Device Farm • Virtual Devices + Physical Devices • Robo Tests & Custom Instrumentation Tests • Pay per hour
  34. Runs on Android

  35. Why run tests on Firebase? • History of results •

    Logs attached to each test • Screenshots & videos • Don’t have to manage your own device farm
  36. Robo Test • Random clicking around in your application +

    recording results • No code changes required to run a Robo Test • Uses Monkey Runner
  37. Running Monkey Locally $ adb shell monkey -p your.package.name -v

    500 Command line:
  38. Running Monkey on Firebase

  39. Viewing Robo Test Results

  40. Instrumentation Tests • Need to be writing test code •

    Espresso • Robotium • UIAutomator
  41. Run Instrumentation Tests Locally • Device / Emulator attached •

    Espresso: ./gradlew connectedAndroidTest
  42. Options for running tests • Firebase Console • Command Line

    - Using gcloud API • Android Studio
  43. Running Instrumentation Tests in Android Studio

  44. Viewing Test Results

  45. Recap •Remote Config •Getting setup •Using remote config •A/B Testing

    + Gradual Roll outs •Test Lab •Robo Tests •Instrumentation tests
  46. Thank you! Rebecca Franks Google Developer Expert - Android @riggaroo

    / +RebeccaFranksSA riggaroo.co.za #LaunchpadDev
  47. Links Firebase Remote Config - https://firebase.google.com/docs/remote-config/ Firebase Test Lab -

    https://firebase.google.com/docs/test-lab/ Testing Support Library - https://developer.android.com/topic/libraries/ testing-support-library/index.html Demo Remote Config Project - https://github.com/riggaroo/remote-config- demo-ssa-launchpad-2016 Demo Test Lab Project - https://github.com/googlesamples/android- testing/tree/master/ui/uiautomator/BasicSample