SlideShare a Scribd company logo
Getting High on Espresso!
X
Ketan Soni
Getting High on Espresso!
• Why do we automate?
• Do you trust your tests 100%?
• Synchronization
Why are they flaky?
Why Flakiness?
UI
Thread
Motion
down
Test
Thread
Click
Motion Up
AssertSleep Assert
ANDROID INSTRUMENTATION FRAMEWORK
Android Test Automation Frameworks
UI Automator
Robotium
Appium
Calabash
JUNIT
Simple & Easy
•Developers/QAs avoid installing heavy tools
•Doesn’t want to learn new language just for
testing stuff.
•Make it easy for developers and QA so that
they do it
Reliable
• do{
Thread.sleep(5000)
} while (!loaded)
assert(“Let me have a coffee until it loads”)
• Synchronizing multiple threads
Durable
• Antonym of fragile
• Test should not break if String of any
resource has changed
• Refer the elements by resource id rather
than content description
ANDROID INSTRUMENTATION FRAMEWORK
Android Test Automation Frameworks
UI Automator
Robotium
Appium
Calabash
JUNIT
How Espresso Works?
Main
Thread
Motion
down
Test
/Instrumentatio
n Thread
Motion Up
Test Case
Some work
in queue
Espresso
AssertAction
Blocked
Enough of talk! Let’s Code
Clone the repository
git@github.com:ketansoni/android-booksearch-
demo.git
Automation scenario
1. Launch app
2. Tap on search icon
3. Search using keyword “Android Testing”
4. Count the number of items returned
5. View the item details
6. Share the item and verify it is shared
How to install?
• Add following in your build.gradle of your app and sync it
dependencies {
//Testing dependencies
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2’
}
• Set the Instrument Runner in android.defaultconfig
android {
defaultConfig {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner”
}
Settings
• On your device, under Settings->Developer options disable the
following 3 settings:
o Window animation scale
o Transition animation scale
o Animator duration scale
Launch app
• In your app/src/androidTest/java/com.codepath.android.booksearch
@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
@Rule
public ActivityTestRule<BookListActivity> mActivityRule
= new ActivityTestRule(BookListActivity.class);
@Test
public void test() {
}
}
Syntax
• onView(Matcher).
perform(ViewActions) .
check(ViewAssertions)
Tap on search Icon
• onView(withId(R.id.action_search)).
perform(click());
Search using keyword
“Android Testing”
• onView(withId(R.id.search_src_text))
.perform(typeText("Android Testing"),
pressKey(KeyEvent.KEYCODE_ENTER));
Count the number of items returned
public static int getListViewCount(final int id) {
final int[] counts = new int[1];
onView(withId(id)).check(matches(new TypeSafeMatcher<View>() {
@Override
public boolean matchesSafely(View view) {
ListView listView = (ListView) view;
counts[0] = listView.getCount();
return true;
}
@Override
public void describeTo(Description description) {
}
}));
return counts[0];
}
assertThat("No. of reminders are: ", getListViewCount(R.id.lvBooks),
CoreMatchers.equalTo(1));
View the item details
onView(withText("Android application testing guide"))
.perform(click());
What is intent?
• Intents facilitate communication between
components called Activities
• Types
– Explicit
– Implicit
Explicit Intent
• E.g. start a service to download a file in the
background
Implicit Intent
• E.g. you want to share a photo
Share the item and verify intent
Add dependencies
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2'
//IntentsRule
public IntentsTestRule<BookListActivity> mActivityRule
= new IntentsTestRule(BookListActivity.class);
Share the item and verify intent
// Build a result to return when a particular activity is launched.
Intent resultData = new Intent();
Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, null);
// Set up result stubbing when an intent sent to "contacts" is seen.
intending(hasAction(Intent.ACTION_SEND)).respondWith(result);
// User action that results in ”external message" activity being launched.
// Launching activity expects title to be returned and displays it on the screen.
onView(withId(R.id.action_share)).perform(click());
// intent validation with existing Intent matchers:
Matcher<Intent> intentMatcher = AllOf.allOf(
hasAction(Intent.ACTION_CHOOSER),
hasExtras(AllOf.allOf(
hasEntry(Matchers.equalTo(Intent.EXTRA_TITLE), Matchers.equalTo("Share Image")))));
// Assert that data we set up above is shown.
intended(intentMatcher);
Command-Line?
• ./gradlew connectedAndroidTest
Need HTML Report?
• Spoon to your rescue
• Awesome library from foursquare
• Spoon runs tests on all devices detected by adb.
• Generates easy, meaningful summary in HTML.
• Takes a screenshot for debugging
• Runs tests parallel on multiple simulators as well
as real devices
Install spoon
• Add into your build script dependencies
buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.2'
classpath 'com.squareup.spoon:spoon-runner:1.2.1'
}
}
apply plugin: 'spoon’
packagingOptions {
exclude 'LICENSE.txt'
}
spoon {
debug = true
adbTimeout = 3000
}
//To Run and generate report
./gradlew spoon
Spoon Reports
Supports
• Intents
oExplicit
oImplicit
• Web control
• Custom ViewMatchers for nested controls
• Custom Failure Handler
Advantages
• Google supports it 
• Blazingly Fast
• Deterministic as test thread is synchronized
with main thread
• Custom Matchers
• Debugging become easy because you can view
nested control using hierarchy viewer
• No new language to be learned specially for
testing
Tools Comparison
Thank you
ketan_soni
ketansony@gmail.com
References:
https://www.raywenderlich.com/103044/android-intents-tutorial
http://testdroid.com/tech/top-5-android-testing-frameworks-with-examples
https://github.com/emmasuzuki/EspressoSpoonDemo

More Related Content

What's hot

"Design First" APIs with Swagger
"Design First" APIs with Swagger"Design First" APIs with Swagger
"Design First" APIs with Swagger
scolestock
 
Automating android
Automating androidAutomating android
Automating android
Melvin Laguren
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
SQABD
 
Api testing
Api testingApi testing
Api testing
Keshav Kashyap
 
Self-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriverSelf-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriver
seleniumconf
 
Office add ins community call - april 2019
Office add ins community call - april 2019Office add ins community call - april 2019
Office add ins community call - april 2019
Microsoft 365 Developer
 
Uncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applicationsUncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applications
Kazuaki Matsuo
 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoT
Yakov Fain
 
Selenium Conference 2015 - Mobile Selenium Grid Setup
Selenium Conference 2015 - Mobile Selenium Grid SetupSelenium Conference 2015 - Mobile Selenium Grid Setup
Selenium Conference 2015 - Mobile Selenium Grid Setup
Justin Ison
 
Selenium Camp 2016 - Kiev, Ukraine
Selenium Camp 2016 -  Kiev, UkraineSelenium Camp 2016 -  Kiev, Ukraine
Selenium Camp 2016 - Kiev, Ukraine
Justin Ison
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
TechWell
 
Automated tests to a REST API
Automated tests to a REST APIAutomated tests to a REST API
Automated tests to a REST API
Luís Barros Nóbrega
 
Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)
Sauce Labs
 
Advanced Appium
Advanced AppiumAdvanced Appium
Advanced Appium
Dan Cuellar
 
Super powered API testing
Super powered API testing Super powered API testing
Super powered API testing
postmanclient
 
Selenium Testing on Chrome - Google DevFest Armenia 2015
Selenium Testing on Chrome - Google DevFest Armenia 2015Selenium Testing on Chrome - Google DevFest Armenia 2015
Selenium Testing on Chrome - Google DevFest Armenia 2015
Sargis Sargsyan
 
Calabash-android
Calabash-androidCalabash-android
Calabash-android
Adnan8990
 
Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
pkslide28
 
How to build testable UIs
How to build testable UIsHow to build testable UIs
How to build testable UIs
Shi Ling Tai
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
b4usolution .
 

What's hot (20)

"Design First" APIs with Swagger
"Design First" APIs with Swagger"Design First" APIs with Swagger
"Design First" APIs with Swagger
 
Automating android
Automating androidAutomating android
Automating android
 
CUCUMBER - Making BDD Fun
CUCUMBER - Making BDD FunCUCUMBER - Making BDD Fun
CUCUMBER - Making BDD Fun
 
Api testing
Api testingApi testing
Api testing
 
Self-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriverSelf-Generating Test Artifacts for Selenium/WebDriver
Self-Generating Test Artifacts for Selenium/WebDriver
 
Office add ins community call - april 2019
Office add ins community call - april 2019Office add ins community call - april 2019
Office add ins community call - april 2019
 
Uncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applicationsUncovering breaking changes behind UI on mobile applications
Uncovering breaking changes behind UI on mobile applications
 
RESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoTRESTful services and OAUTH protocol in IoT
RESTful services and OAUTH protocol in IoT
 
Selenium Conference 2015 - Mobile Selenium Grid Setup
Selenium Conference 2015 - Mobile Selenium Grid SetupSelenium Conference 2015 - Mobile Selenium Grid Setup
Selenium Conference 2015 - Mobile Selenium Grid Setup
 
Selenium Camp 2016 - Kiev, Ukraine
Selenium Camp 2016 -  Kiev, UkraineSelenium Camp 2016 -  Kiev, Ukraine
Selenium Camp 2016 - Kiev, Ukraine
 
Implementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using CucumberImplementing Testing for Behavior-Driven Development Using Cucumber
Implementing Testing for Behavior-Driven Development Using Cucumber
 
Automated tests to a REST API
Automated tests to a REST APIAutomated tests to a REST API
Automated tests to a REST API
 
Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)Best Practices in Mobile CI (webinar)
Best Practices in Mobile CI (webinar)
 
Advanced Appium
Advanced AppiumAdvanced Appium
Advanced Appium
 
Super powered API testing
Super powered API testing Super powered API testing
Super powered API testing
 
Selenium Testing on Chrome - Google DevFest Armenia 2015
Selenium Testing on Chrome - Google DevFest Armenia 2015Selenium Testing on Chrome - Google DevFest Armenia 2015
Selenium Testing on Chrome - Google DevFest Armenia 2015
 
Calabash-android
Calabash-androidCalabash-android
Calabash-android
 
Ppt of soap ui
Ppt of soap uiPpt of soap ui
Ppt of soap ui
 
How to build testable UIs
How to build testable UIsHow to build testable UIs
How to build testable UIs
 
B4USolution_API-Testing
B4USolution_API-TestingB4USolution_API-Testing
B4USolution_API-Testing
 

Viewers also liked

Re-contextualising Business Discourse through the Web. The Case of Global Cor...
Re-contextualising Business Discourse through the Web. The Case of Global Cor...Re-contextualising Business Discourse through the Web. The Case of Global Cor...
Re-contextualising Business Discourse through the Web. The Case of Global Cor...
Emanuela Tenca
 
Bracket prescriptions partii /cosmetic dentistry courses
Bracket prescriptions partii /cosmetic dentistry coursesBracket prescriptions partii /cosmetic dentistry courses
Bracket prescriptions partii /cosmetic dentistry courses
Indian dental academy
 
ABC Conference - ZTLCC
ABC Conference - ZTLCCABC Conference - ZTLCC
ABC Conference - ZTLCC
graemeslaght
 
Biomechanics of molar distalization
Biomechanics of molar distalizationBiomechanics of molar distalization
Biomechanics of molar distalization
Indian dental academy
 
Nightclub sound systems
Nightclub sound systemsNightclub sound systems
Nightclub sound systems
Abhinav Chaudhary
 
Accounting basics
Accounting basicsAccounting basics
Accounting basics
Sabyasachi Srimany
 
Azure gov march 15th
Azure gov march 15thAzure gov march 15th
Azure gov march 15th
Ashna Khorana, PRC
 
LexisNexis File & Serve Available Courts
LexisNexis File & Serve Available CourtsLexisNexis File & Serve Available Courts
LexisNexis File & Serve Available Courts
kendallsmith
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
VISHAL DONGA
 
Finishing & detailing in orthodontics / fixed orthodontics course
Finishing & detailing in orthodontics / fixed orthodontics courseFinishing & detailing in orthodontics / fixed orthodontics course
Finishing & detailing in orthodontics / fixed orthodontics course
Indian dental academy
 
Secuencia Didáctica de Ciencias Naturales
Secuencia Didáctica de Ciencias NaturalesSecuencia Didáctica de Ciencias Naturales
Secuencia Didáctica de Ciencias Naturales
Daniela Vera Alarcón
 
Alexanders vari simplex discipline
Alexanders vari simplex disciplineAlexanders vari simplex discipline
Alexanders vari simplex discipline
Saeed Bajafar
 
Modified beggs /certified fixed orthodontic courses by Indian dental academy
Modified beggs /certified fixed orthodontic courses by Indian dental academy Modified beggs /certified fixed orthodontic courses by Indian dental academy
Modified beggs /certified fixed orthodontic courses by Indian dental academy
Indian dental academy
 
Class 2. div 2
Class 2. div 2Class 2. div 2
Class 2. div 2
Indian dental academy
 
Postero anterior cephalometric _ mansoura university _ Egypt
Postero anterior cephalometric _  mansoura university _ EgyptPostero anterior cephalometric _  mansoura university _ Egypt
Postero anterior cephalometric _ mansoura university _ Egypt
ameen qulah
 
Headgear..
Headgear..Headgear..
The headgear /certified fixed orthodontic courses by Indian dental academy
The headgear  /certified fixed orthodontic courses by Indian dental academy The headgear  /certified fixed orthodontic courses by Indian dental academy
The headgear /certified fixed orthodontic courses by Indian dental academy
Indian dental academy
 
Ch3 Orthodontics "management of developing dentition
Ch3 Orthodontics  "management of developing dentitionCh3 Orthodontics  "management of developing dentition
Ch3 Orthodontics "management of developing dentition
Cezar Edward Lahham
 
anchorage
anchorageanchorage
anchorage
Parth Thakkar
 
Chin cup for treatment of growing class III patient
Chin cup for treatment of growing class III patientChin cup for treatment of growing class III patient
Chin cup for treatment of growing class III patient
bilal falahi
 

Viewers also liked (20)

Re-contextualising Business Discourse through the Web. The Case of Global Cor...
Re-contextualising Business Discourse through the Web. The Case of Global Cor...Re-contextualising Business Discourse through the Web. The Case of Global Cor...
Re-contextualising Business Discourse through the Web. The Case of Global Cor...
 
Bracket prescriptions partii /cosmetic dentistry courses
Bracket prescriptions partii /cosmetic dentistry coursesBracket prescriptions partii /cosmetic dentistry courses
Bracket prescriptions partii /cosmetic dentistry courses
 
ABC Conference - ZTLCC
ABC Conference - ZTLCCABC Conference - ZTLCC
ABC Conference - ZTLCC
 
Biomechanics of molar distalization
Biomechanics of molar distalizationBiomechanics of molar distalization
Biomechanics of molar distalization
 
Nightclub sound systems
Nightclub sound systemsNightclub sound systems
Nightclub sound systems
 
Accounting basics
Accounting basicsAccounting basics
Accounting basics
 
Azure gov march 15th
Azure gov march 15thAzure gov march 15th
Azure gov march 15th
 
LexisNexis File & Serve Available Courts
LexisNexis File & Serve Available CourtsLexisNexis File & Serve Available Courts
LexisNexis File & Serve Available Courts
 
Cache memory and cache
Cache memory and cacheCache memory and cache
Cache memory and cache
 
Finishing & detailing in orthodontics / fixed orthodontics course
Finishing & detailing in orthodontics / fixed orthodontics courseFinishing & detailing in orthodontics / fixed orthodontics course
Finishing & detailing in orthodontics / fixed orthodontics course
 
Secuencia Didáctica de Ciencias Naturales
Secuencia Didáctica de Ciencias NaturalesSecuencia Didáctica de Ciencias Naturales
Secuencia Didáctica de Ciencias Naturales
 
Alexanders vari simplex discipline
Alexanders vari simplex disciplineAlexanders vari simplex discipline
Alexanders vari simplex discipline
 
Modified beggs /certified fixed orthodontic courses by Indian dental academy
Modified beggs /certified fixed orthodontic courses by Indian dental academy Modified beggs /certified fixed orthodontic courses by Indian dental academy
Modified beggs /certified fixed orthodontic courses by Indian dental academy
 
Class 2. div 2
Class 2. div 2Class 2. div 2
Class 2. div 2
 
Postero anterior cephalometric _ mansoura university _ Egypt
Postero anterior cephalometric _  mansoura university _ EgyptPostero anterior cephalometric _  mansoura university _ Egypt
Postero anterior cephalometric _ mansoura university _ Egypt
 
Headgear..
Headgear..Headgear..
Headgear..
 
The headgear /certified fixed orthodontic courses by Indian dental academy
The headgear  /certified fixed orthodontic courses by Indian dental academy The headgear  /certified fixed orthodontic courses by Indian dental academy
The headgear /certified fixed orthodontic courses by Indian dental academy
 
Ch3 Orthodontics "management of developing dentition
Ch3 Orthodontics  "management of developing dentitionCh3 Orthodontics  "management of developing dentition
Ch3 Orthodontics "management of developing dentition
 
anchorage
anchorageanchorage
anchorage
 
Chin cup for treatment of growing class III patient
Chin cup for treatment of growing class III patientChin cup for treatment of growing class III patient
Chin cup for treatment of growing class III patient
 

Similar to Espresso workshop

Automated Testing on iOS
Automated Testing on iOSAutomated Testing on iOS
Automated Testing on iOS
Make School
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
Hussain Behestee
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
Pratik Patel
 
QTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.pptQTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.ppt
Kalyan Chakravarthy
 
Functional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with FrankensteinFunctional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with Frankenstein
vivek_prahlad
 
Xam expertday
Xam expertdayXam expertday
Xam expertday
Codrina Merigo
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
Alessandro Giorgetti
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Flutter Agency
 
Use Jenkins For Continuous Load Testing And Mobile Test Automation
Use Jenkins For Continuous Load Testing And Mobile Test AutomationUse Jenkins For Continuous Load Testing And Mobile Test Automation
Use Jenkins For Continuous Load Testing And Mobile Test Automation
Clever Moe
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
Srijan Technologies
 
STARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test Automation
STARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test AutomationSTARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test Automation
STARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test Automation
Clever Moe
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
Mohab El-Shishtawy
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO
Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIOJumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO
Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO
Josh Cypher
 
Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)
Yan Cui
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Code
jameshalsall
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
Lars Vogel
 
Qtp certification training_material
Qtp certification training_materialQtp certification training_material
Qtp certification training_material
Vishwaprakash Sahoo
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
Michael Fons
 
QTP Tutorial
QTP TutorialQTP Tutorial
QTP Tutorial
pingkapil
 

Similar to Espresso workshop (20)

Automated Testing on iOS
Automated Testing on iOSAutomated Testing on iOS
Automated Testing on iOS
 
iOS app dev Training - Session1
iOS app dev Training - Session1iOS app dev Training - Session1
iOS app dev Training - Session1
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
QTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.pptQTP 10.0_Kalyan Chakravarthy.ppt
QTP 10.0_Kalyan Chakravarthy.ppt
 
Functional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with FrankensteinFunctional Testing Swing Applications with Frankenstein
Functional Testing Swing Applications with Frankenstein
 
Xam expertday
Xam expertdayXam expertday
Xam expertday
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Use Jenkins For Continuous Load Testing And Mobile Test Automation
Use Jenkins For Continuous Load Testing And Mobile Test AutomationUse Jenkins For Continuous Load Testing And Mobile Test Automation
Use Jenkins For Continuous Load Testing And Mobile Test Automation
 
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
[Srijan Wednesday Webinar] Mastering Mobile Test Automation with Appium
 
STARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test Automation
STARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test AutomationSTARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test Automation
STARWest: Use Jenkins For Continuous 
Load Testing And Mobile Test Automation
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO
Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIOJumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO
Jumpstarting Testing In Your Organization with Selenium, Cucumber, & WebdriverIO
 
Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)Serverless in production, an experience report (JeffConf)
Serverless in production, an experience report (JeffConf)
 
Writing Testable Code
Writing Testable CodeWriting Testable Code
Writing Testable Code
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Qtp certification training_material
Qtp certification training_materialQtp certification training_material
Qtp certification training_material
 
Testing Options in Java
Testing Options in JavaTesting Options in Java
Testing Options in Java
 
QTP Tutorial
QTP TutorialQTP Tutorial
QTP Tutorial
 

Recently uploaded

zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
YousufSait3
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
Octavian Nadolu
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
ShulagnaSarkar2
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
Remote DBA Services
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
kalichargn70th171
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
Bert Jan Schrijver
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
mz5nrf0n
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
rodomar2
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
Quickdice ERP
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
safelyiotech
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
Peter Muessig
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
GohKiangHock
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
gapen1
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
Peter Muessig
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
Hornet Dynamics
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
kalichargn70th171
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
ISH Technologies
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
brainerhub1
 

Recently uploaded (20)

zOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL DifferenceszOS Mainframe JES2-JES3 JCL-JECL Differences
zOS Mainframe JES2-JES3 JCL-JECL Differences
 
Artificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension FunctionsArtificia Intellicence and XPath Extension Functions
Artificia Intellicence and XPath Extension Functions
 
14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision14 th Edition of International conference on computer vision
14 th Edition of International conference on computer vision
 
Oracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptxOracle Database 19c New Features for DBAs and Developers.pptx
Oracle Database 19c New Features for DBAs and Developers.pptx
 
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
The Key to Digital Success_ A Comprehensive Guide to Continuous Testing Integ...
 
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
J-Spring 2024 - Going serverless with Quarkus, GraalVM native images and AWS ...
 
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
在线购买加拿大英属哥伦比亚大学毕业证本科学位证书原版一模一样
 
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CDKuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
KuberTENes Birthday Bash Guadalajara - Introducción a Argo CD
 
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian CompaniesE-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
E-Invoicing Implementation: A Step-by-Step Guide for Saudi Arabian Companies
 
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
Safelyio Toolbox Talk Softwate & App (How To Digitize Safety Meetings)
 
UI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design SystemUI5con 2024 - Bring Your Own Design System
UI5con 2024 - Bring Your Own Design System
 
SQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure MalaysiaSQL Accounting Software Brochure Malaysia
SQL Accounting Software Brochure Malaysia
 
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
如何办理(hull学位证书)英国赫尔大学毕业证硕士文凭原版一模一样
 
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling ExtensionsUI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
UI5con 2024 - Boost Your Development Experience with UI5 Tooling Extensions
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
E-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet DynamicsE-commerce Development Services- Hornet Dynamics
E-commerce Development Services- Hornet Dynamics
 
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf8 Best Automated Android App Testing Tool and Framework in 2024.pdf
8 Best Automated Android App Testing Tool and Framework in 2024.pdf
 
Preparing Non - Technical Founders for Engaging a Tech Agency
Preparing Non - Technical Founders for Engaging  a  Tech AgencyPreparing Non - Technical Founders for Engaging  a  Tech Agency
Preparing Non - Technical Founders for Engaging a Tech Agency
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Unveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdfUnveiling the Advantages of Agile Software Development.pdf
Unveiling the Advantages of Agile Software Development.pdf
 

Espresso workshop

  • 1. Getting High on Espresso! X Ketan Soni Getting High on Espresso!
  • 2. • Why do we automate?
  • 3. • Do you trust your tests 100%?
  • 4.
  • 5.
  • 8. ANDROID INSTRUMENTATION FRAMEWORK Android Test Automation Frameworks UI Automator Robotium Appium Calabash JUNIT
  • 9. Simple & Easy •Developers/QAs avoid installing heavy tools •Doesn’t want to learn new language just for testing stuff. •Make it easy for developers and QA so that they do it
  • 10. Reliable • do{ Thread.sleep(5000) } while (!loaded) assert(“Let me have a coffee until it loads”) • Synchronizing multiple threads
  • 11. Durable • Antonym of fragile • Test should not break if String of any resource has changed • Refer the elements by resource id rather than content description
  • 12. ANDROID INSTRUMENTATION FRAMEWORK Android Test Automation Frameworks UI Automator Robotium Appium Calabash JUNIT
  • 13. How Espresso Works? Main Thread Motion down Test /Instrumentatio n Thread Motion Up Test Case Some work in queue Espresso AssertAction Blocked
  • 14. Enough of talk! Let’s Code Clone the repository git@github.com:ketansoni/android-booksearch- demo.git
  • 15. Automation scenario 1. Launch app 2. Tap on search icon 3. Search using keyword “Android Testing” 4. Count the number of items returned 5. View the item details 6. Share the item and verify it is shared
  • 16. How to install? • Add following in your build.gradle of your app and sync it dependencies { //Testing dependencies androidTestCompile 'com.android.support.test:runner:0.5' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2’ } • Set the Instrument Runner in android.defaultconfig android { defaultConfig { testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner” }
  • 17. Settings • On your device, under Settings->Developer options disable the following 3 settings: o Window animation scale o Transition animation scale o Animator duration scale
  • 18. Launch app • In your app/src/androidTest/java/com.codepath.android.booksearch @RunWith(AndroidJUnit4.class) public class ApplicationTest { @Rule public ActivityTestRule<BookListActivity> mActivityRule = new ActivityTestRule(BookListActivity.class); @Test public void test() { } }
  • 20. Tap on search Icon • onView(withId(R.id.action_search)). perform(click());
  • 21. Search using keyword “Android Testing” • onView(withId(R.id.search_src_text)) .perform(typeText("Android Testing"), pressKey(KeyEvent.KEYCODE_ENTER));
  • 22. Count the number of items returned public static int getListViewCount(final int id) { final int[] counts = new int[1]; onView(withId(id)).check(matches(new TypeSafeMatcher<View>() { @Override public boolean matchesSafely(View view) { ListView listView = (ListView) view; counts[0] = listView.getCount(); return true; } @Override public void describeTo(Description description) { } })); return counts[0]; } assertThat("No. of reminders are: ", getListViewCount(R.id.lvBooks), CoreMatchers.equalTo(1));
  • 23. View the item details onView(withText("Android application testing guide")) .perform(click());
  • 24. What is intent? • Intents facilitate communication between components called Activities • Types – Explicit – Implicit
  • 25. Explicit Intent • E.g. start a service to download a file in the background
  • 26. Implicit Intent • E.g. you want to share a photo
  • 27. Share the item and verify intent Add dependencies androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2' //IntentsRule public IntentsTestRule<BookListActivity> mActivityRule = new IntentsTestRule(BookListActivity.class);
  • 28. Share the item and verify intent // Build a result to return when a particular activity is launched. Intent resultData = new Intent(); Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, null); // Set up result stubbing when an intent sent to "contacts" is seen. intending(hasAction(Intent.ACTION_SEND)).respondWith(result); // User action that results in ”external message" activity being launched. // Launching activity expects title to be returned and displays it on the screen. onView(withId(R.id.action_share)).perform(click()); // intent validation with existing Intent matchers: Matcher<Intent> intentMatcher = AllOf.allOf( hasAction(Intent.ACTION_CHOOSER), hasExtras(AllOf.allOf( hasEntry(Matchers.equalTo(Intent.EXTRA_TITLE), Matchers.equalTo("Share Image"))))); // Assert that data we set up above is shown. intended(intentMatcher);
  • 30. Need HTML Report? • Spoon to your rescue • Awesome library from foursquare • Spoon runs tests on all devices detected by adb. • Generates easy, meaningful summary in HTML. • Takes a screenshot for debugging • Runs tests parallel on multiple simulators as well as real devices
  • 31. Install spoon • Add into your build script dependencies buildscript { repositories { mavenCentral() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.0.2' classpath 'com.squareup.spoon:spoon-runner:1.2.1' } } apply plugin: 'spoon’ packagingOptions { exclude 'LICENSE.txt' } spoon { debug = true adbTimeout = 3000 } //To Run and generate report ./gradlew spoon
  • 33.
  • 34. Supports • Intents oExplicit oImplicit • Web control • Custom ViewMatchers for nested controls • Custom Failure Handler
  • 35. Advantages • Google supports it  • Blazingly Fast • Deterministic as test thread is synchronized with main thread • Custom Matchers • Debugging become easy because you can view nested control using hierarchy viewer • No new language to be learned specially for testing

Editor's Notes

  1. Agenda How many over here does mobile test automation? How many have worked on android application?
  2. Saving time and do more exploratory testing? Safety net? Who all gets benefitted because of it?
  3. Does developers trusts your test suite? How many over here can say that yes developers trust the suite completely?
  4. Have you experienced this? How many have experience this? Devs just loose trust and then the blame game starts Brittle? Flaky?
  5. When devs says your UI tests just suck. How many have read about non-deterministic failure blog of martin fowler?
  6. What causes flakiness? Any example? How do you solve this problem? Anyone? Sleep? Is it a good idea? What are the problems that you encounter?
  7. Tried evaluating these framework but weren’t happy with set of issue people were facing. Developers weren't happy and lost trust.
  8. Why espresso?
  9. Most important aspect of choosing espresso Register a resource with Espresso Tell Espresso when your resource is going to go idle so that Espresso will wait until it becomes active again If Crash, catch all the exception and propagate these in user friendly format to the test
  10. It becomes easy to refactor
  11. Tried evaluating these framework but weren’t happy with set of issue people were facing.
  12. This will install your dependencies
  13. Clone the app or copy This will install your dependencies
  14. Why?
  15. Launch App
  16. Launch App
  17. This will install your dependencies
  18. Other factors Hermetic testing etc.