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

Mobile Testing in the cloud

Mobile Testing in the cloud

Android has a fragmented ecosystem. There are devices out there with square screens or even no 3G antenna. It’s impossible to test on all of them. But if we write automated tests, then maybe we could run these tests on hundreds of real devices in the cloud. Let’s compare Espresso to Appium and Amazon Device Farm to Firebase Device Lab and see which of these we like more.

Presented at:
- Codecamp Iasi Autumn 2016
- MBLTdev Moscow 2016
- Codecamp Cluj Autumn 2016
- DevFest Romania 2016

Andrei Diaconu

November 25, 2016
Tweet

More Decks by Andrei Diaconu

Other Decks in Programming

Transcript

  1. Mobile testing
    in the cloud
    Andrei Diaconu

    View full-size slide

  2. http://www.andreidiaconu.com http://www.androidiasi.ro
    Andrei Diaconu Android Iasi
    Me

    View full-size slide

  3. 1. Mobile testing
    2. in the cloud

    View full-size slide

  4. 2 Options
    Simple Java Unit Tests
    UI tests

    View full-size slide

  5. 2 Options
    Simple Java Unit Tests
    UI tests
    Test components in isolation
    Super fast

    View full-size slide

  6. 2 Options
    Simple Java Unit Tests
    UI tests
    Test components in isolation
    Super fast
    Simulate user interaction
    Slow and need Android

    View full-size slide

  7. Inside man Outside man

    View full-size slide

  8. Inside man Outside man
    • Access to code
    • Can change anything
    • Can simulate situations
    • Uses accessibility
    • Simulates a user
    • Can run on any app

    View full-size slide

  9. Inside man Outside man

    View full-size slide

  10. Inside man Outside man
    Instrumentation
    Framework
    UiAutomator

    View full-size slide

  11. Inside man Outside man

    View full-size slide

  12. How they work

    View full-size slide

  13. UiAutomator
    AppiumDriver
    JUnit

    View full-size slide

  14. Instrumentation
    Framework
    JUnit

    View full-size slide

  15. Instrumentation
    Framework
    UiAutomator
    JUnit

    View full-size slide

  16. Let's validate
    this scenario

    View full-size slide

  17. onView(withText("Favorites"))

    .perform(click());

    onView(withId(R.id.swipe_to_refresh))

    .perform(swipeDown());


    onView(withText(containsString("There are no Sessions")))

    .check(matches(isDisplayed()));

    View full-size slide

  18. onView(withText("Favorites"))

    .perform(click());

    onView(withId(R.id.swipe_to_refresh))

    .perform(swipeDown());


    onView(withText(containsString("There are no Sessions")))

    .check(matches(isDisplayed()));

    View full-size slide

  19. onView(withText("Favorites"))

    .perform(click());

    onView(withId(R.id.swipe_to_refresh))

    .perform(swipeDown());


    onView(withText(containsString("There are no Sessions")))

    .check(matches(isDisplayed()));

    View full-size slide

  20. Let's validate
    this scenario

    View full-size slide

  21. Record from Android Studio

    View full-size slide

  22. driver
    .findElement(containsText("Favorites"))

    .click();

    driver.swipe(300, 300, 300, 600, 1500);


    assertTrue(
    driver
    .findElement(containsText("There are no Sessions"))

    .isDisplayed());
    ...
    private By containsText(String text){

    return By.xpath("//*[contains(@text,'"+text+"')]");

    }

    View full-size slide

  23. driver
    .findElement(containsText("Favorites"))

    .click();

    driver.swipe(300, 300, 300, 600, 1500);


    assertTrue(
    driver
    .findElement(containsText("There are no Sessions"))

    .isDisplayed());
    ...
    private By containsText(String text){

    return By.xpath("//*[contains(@text,'"+text+"')]");

    }

    View full-size slide

  24. driver
    .findElement(containsText("Favorites"))

    .click();

    driver.swipe(300, 300, 300, 600, 1500);


    assertTrue(
    driver
    .findElement(containsText("There are no Sessions"))

    .isDisplayed());
    ...
    private By containsText(String text){

    return By.xpath("//*[contains(@text,'"+text+"')]");

    }

    View full-size slide

  25. driver
    .findElement(containsText("Favorites"))

    .click();

    driver.swipe(300, 300, 300, 600, 1500);


    assertTrue(
    driver
    .findElement(containsText("There are no Sessions"))

    .isDisplayed());
    ...
    private By containsText(String text){

    return By.xpath("//*[contains(@text,'"+text+"')]");

    }

    View full-size slide

  26. Mobile testing
    in the cloud

    View full-size slide

  27. in the cloud

    View full-size slide

  28. Firebase Test Lab

    View full-size slide

  29. Upload app and instrumentation apk

    View full-size slide

  30. Select devices and configurations

    View full-size slide

  31. Wait for tests to complete

    View full-size slide

  32. View results, including Screenshots + Video

    View full-size slide

  33. Galaxy Tab 3
    Nexus 7
    Nexus 5
    Nexus 4
    Lg G3

    View full-size slide

  34. Select devices and configurations

    View full-size slide

  35. Configure from Android Studio

    View full-size slide

  36. Run from Android Studio

    View full-size slide

  37. Amazon Device Farm

    View full-size slide

  38. More options,
    including Appium

    View full-size slide

  39. More devices

    View full-size slide

  40. Knows a few other tricks

    View full-size slide

  41. On Amazon you can also manual test

    View full-size slide

  42. So what should you pick?
    OR
    OR

    View full-size slide

  43. Record from Android Studio

    View full-size slide

  44. Firebase codelab (including Jenkins integration):
    https://codelabs.developers.google.com/codelabs/firebase-test-lab/index.html
    Testing codelab (including Espresso):
    https://codelabs.developers.google.com/codelabs/android-testing/#0
    Codecamp App:
    https://play.google.com/store/apps/details?id=ro.androidiasi.codecamp.iasi.live
    Android Iasi:
    http://androidiasi.ro
    Android Iasi Discussion Group:
    http://bit.ly/android-iasi
    Resources

    View full-size slide

  45. http://www.androidiasi.ro
    http://bit.ly/android-iasi

    View full-size slide