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

John Shelley

January 12, 2016
Tweet

More Decks by John Shelley

Other Decks in Programming

Transcript

  1. 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?
  2. /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)
  3. 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.
  4. MVP

  5. MVP

  6. MVP

  7. 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)
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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.
  13. 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.
  14. 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