Testdroid: Testing Your Android and iOS Apps with Appium in Testdroid Cloud
Testdroid: Do You Enjoy Espresso in Android App Testing?
-
Upload
bitbar -
Category
Technology
-
view
1.076 -
download
1
description
Transcript of Testdroid: Do You Enjoy Espresso in Android App Testing?
webinar
Do You Enjoy Espresso in Android App Testing?
6 February 2014
Ville-Veikko HelppiTechnical Product [email protected]
POLL:What is your primary test automation framework?
(for Android)
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
2
webinar
Agenda• Testdroid Update!• Espresso – What Are We Talking About?• Get Up and Running with Espresso – 3 Steps• Hands-On with Eclipse + Testdroid Cloud• Q&A
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
3
Agenda• Testdroid Update!• Espresso – What Are We Talking About?• Get Up and Running with Espresso – 3 Steps• Hands-On with Eclipse + Testdroid Cloud• Q&A
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
4
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
5
FREE DEVICES
Testdroid ProductsComplete Solution for Mobile Apps/Games Testing
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
6
webinar
Testdroid Pricing– No More Unpredictable App Testing Costs!
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
7
webinar
Testdroid Blog and Webinars– Because it is important to know how to automate your testing!
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
8
webinar
POLL:Do you use/have you used
Espresso?
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
9
webinar
Agenda• Testdroid Update!• Espresso – What Are We Talking About?• Get Up and Running with Espresso – 3 Steps• Hands-On with Eclipse + Testdroid Cloud• Q&A
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
10
Android Test Automation Frameworks - The Family Tree
webinar
JUnit
Android Instrumentation Framework
Robotium Espresso
UI Automator
Calabash
Appium
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
11
Android Test Automation Frameworks - The Family Tree
webinar
JUnit
Android Instrumentation Framework
Robotium Espresso
UI Automator
Calabash
Appium
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
12
Robotium – uiautomator – Espressowebinar
• Robotium:
• uiautomator:
• Espresso:
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
13
int index = 0;Button buttonToFind;for (Button button : solo.getCurrentViews(Button.class)) { if (button.getText().contains("the")) { index++; if (index == 5) { buttonToFind = button; break; } }}
new UiSelector().className("Button").textContains("the").index(4)
onView(withId(getInstrumentation().getTargetContext().getResources() .getIdentifier(”app.name.android:id/button", null, null)))
.perform(click());
Android Instrumentation Framework
webinar
• InstrumentationTestRunner – the primary plumbing for running tests on Android
• Android Instrumentation Framework is built on top of JUnit – a standard test framework on for any Java development
• Mock objects – methods for creating mock system objects such as content, service and intent.
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
14
Espresso by Google – Basics webinar
• Light-weight abstraction (only 600 lines of code)• Easy to setup & easily extendable• Time-independent• Backward compatibility (supporting various API levels)• A custom Instrumentation Testrunner with special privileges• Works on API levels 8 (Froyo), 10 (Gingerbread), 15-19 (IJK)• Thin layer on top of Android Instrumentation Framework• Uses the Hamcrest matcher library
https://github.com/hamcrest
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
15
Espresso by Google – Basics 2webinar
• Easy API for extending the framework:– You can write new matchers: onView(myCustomMatcher<View>)– You can write new actions: perform(myCustomAction)– You can write new checks: check(myCustomAssertion)
• Reliable: Synchronizes with the UI thread• It’s fast because there is no need for any sleeps (tests run on
same millisecond when the app becomes idle)• No support for web views and missing screenshot functions• More information Espresso can be found here:
– https://code.google.com/p/android-test-kit/
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
16
How Espresso Compares to Others?webinar
Espresso Robotium uiautomator Calabash Appium
Android Yes Yes Yes Yes Yes
iOS No No No No Yes
Mobile web No Yes (Android)
Limited to x.y clicks
Hybrid(webviews)
Yes (Android & iOS)
Scripting Language
Java Java Java Roby Almost any
Test creation tools
Hierarchy Viewer
Testdroid Recorder
UI Automator viewer
CLI Appium.app
Supported API levels
8, 10, 15-19 All 16 => All All
Community Google Contributors Google Semi-Active Active
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
17
Easy-to-Learn Espresso Syntaxwebinar
• OnView
• Check if view with the text “Hello” is shown
• R class ID identifier for “Sign in” – and click on it
• Type text in text field
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
18
import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
onView(withText("Hello")).check(matches(isDisplayed()));
onView(withId(getInstrumentation().getTargetContext().getResources() .getIdentifier("com.twitter.android:id/sign_in", null, null))) .perform(click());
onView(withId(getInstrumentation().getTargetContext().getResources() .getIdentifier("com.twitter.android:id/edit", null, null)))
.perform((typeText("Testdroid is awesome!")));
Agenda• Testdroid Update!• Espresso – What Are We Talking About?• Get Up and Running with Espresso – 3 Steps• Hands-On with Eclipse + Testdroid Cloud• Q&A
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
19
Getting Started - Requirementswebinar
• Use the latest standalone JAR from Android Test Kit page:– https://code.google.com/p/android-test-kit/
• Reference this JAR in your test project– Right click on project -> Properties -> Java Build
Path -> Add External JARs• The current version:– espresso-1.1-bundled.jar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
20
1
Mods in Android Manifest filewebinar
2• Update AndroidManifest.xml with two things:– Specify instrumentation test runner & – Include “uses-library” -> BUILD THE PACKAGE
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved. 21
Go to https://cloud.testdroid.com
webinar
3• Under Projects menu, create Android project• Select Full test run
• Upload your APK and test APK• Select Advanced Configuration -> Test execution -> Custom test runner
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved. 22
1
2
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved. 23
com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner3
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved. 24
4
Espresso – Better with Emulators?• Emulators won’t help you to test…– User Experience and Usability– Hardware– Software– Infrastructure
webinar
0 % = the percentage of your app users that use emulator to run your app!
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
25
Check List for Espresso Users• Testing environment as authentic as possible– Real devices <-> emulators/simulators
• Test coverage needs to be adequate– Software is not identical in all Android devices– Hardware is even more fragmented landscape
• Surrounding testing conditions (e.g. network) • Try not to build in repetitive, manual processes• Is Espresso framework that works for you?
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
26
What Framework Works You The Best?• App still under development– High-level & declarative test automation frameworks
work well – More UI specific – e.g. Espresso – requires some details
about app under development• Easy to integrate with continuous integration?• Distance between use case and actual test?• What do you build: Native, Hybrid or Web app?• The technical competence in your organization?• Desired outcome from test automation?
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
27
Why Espresso is A Good Choice? • Easy to Setup & Extend – Based on Standard Android Instrumentation
• Reliable: Synchronizes with the UI thread• It’s fast because there is no need for any sleeps
(tests run on same millisecond when the app becomes idle)
• Time-independent• Google!
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
28
Agenda• Testdroid Update!• Espresso – What Are We Talking About?• Get Up and Running with Espresso – 3 Steps• Hands-On with Eclipse + Testdroid Cloud• Q&A
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
29
Agenda• Testdroid Update!• Espresso – What Are We Talking About?• Get Up and Running with Espresso – 3 Steps• Hands-On with Eclipse + Testdroid Cloud• Q&A
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
30
webinar
© Copyrights by Bitbar Technologies Ltd. 2014 All rights reserved.
31