Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Android Testing: GCTL

Android Testing: GCTL

High Level talk about testing effectively in Android, how best to architect your code for it, and how to make use of Google Cloud Test Labs.
https://www.youtube.com/watch?v=mB99GYu9fRQ

Acb8c985ddf8a03c218569e471cc7322?s=128

John Shelley

January 12, 2016
Tweet

Transcript

  1. Android Testing Testing and Google Cloud Test Lab

  2. John Shelley Android Developer @ Hudl Video Playback Squad twitter:

    @jpshells
  3. twitter: @HudlEngineering

  4. Testing Architecture Google Cloud Test Lab

  5. Why do we need Tests? • Catch more mistakes in

    your code • Confidently make more changes and refactors • Leverage regression testing when adding new features • Make our users happy • Why not?
  6. What types of tests are there?

  7. ‘/test’ vs ‘/androidTest’

  8. /test vs /androidTest • Location of local tests • JUnit4

    • Runs on the JVM • Try not to use the Android Framework • Fast! • Location of Instrumentation tests • Espresso • Runs on a device, emulator, or cloud • Uses the Android Framework! • Consider a “mock” flavor so you don’t hit your API every time. DIP • Watch out for Idling Resources • Slowish… (Turn off hardware animations to speed things up)
  9. None
  10. None
  11. Architecture

  12. MVP • The model provides and stores the internal data.

    • The view handles the display of data (ie. the model). User actions are forwarded to the presenter. • The presenter sits between the model and view; it coordinates the UI with the data, ensuring they are in sync.
  13. MVP

  14. MVP

  15. MVP

  16. Cloud Test Lab

  17. Overview • Cloud-based infrastructure for testing Android apps • Wide

    variety of devices and device configurations • Logs, videos, and screenshots • Exercise your app automatically, looking for crashes • Web, Android Studio, Command Line (“gcloud” CLI)
  18. Setup • Android Studio 1.4+ • Join the Google Group:

    https://groups.google.com/forum/#!forum/omaha-android- dev-meetup-01-16 • Get the sample code: git clone https://github.com/googlesamples/android-testing.git
  19. Setup -2 • Navigate to the BasicSample project main directory

    • In the BasicSample project main directory, run the following commands to build the app binaries and tests • The binaries are now available at: “$ ls app/build/outputs/apk/ • The app binary is called: app-debug-unaligned.apk • The test binary is called: app-debug-androidTest-unaligned.apk
  20. Run your test - web • Navigate to the Cloud

    Test Lab URL to run your first test: https://console. developers.google.com/testlab/mobile/run?project=omaha-android-dev-meetup • Run an Instrumentation Test • On the following page, upload your app and the test APKs obtained from the previous step, configure your test matrix, and then start the test
  21. Setup - Studio • Follow the instructions here, to create

    a new studio.vmoptions file (or edit an existing one): http://tools.android.com/tech-docs/configuration • Add the following to the file: -Denable.google.cloud.testing.plugin=true
  22. Import & Run • Select the BasicSample directory from the

    sample code folder. • Install any missing packages and resolve suggested conflicts • Click the Gradle sync button. Resolve all issues.
  23. Import & Run

  24. Import & Run

  25. Import & Run • Under “Cloud device matrix”, you can

    provide a different “Matrix configuration” by clicking on the “more” icon and creating a different configuration. • Click “Apply” and close the window. • Now you can run the test by clicking the Run configuration icon in Android Studio.
  26. What if I don’t have any tests?

  27. Robo Tests • Better version of Android Monkey Runner. •

    Depth First Search traversal of screens. • Navigate to: https://console.developers.google.com/testlab/mobile/run/robo? project=omaha-android-dev-meetup • Upload your App’s APK only, configure the test matrix and start the test
  28. Congratulations! Resources: • https://codelabs.developers.google.com/codelabs/android-testing/index.html • https://codelabs.developers.google.com/codelabs/cloud-test-lab/index.html