SlideShare une entreprise Scribd logo
1  sur  19
Android Automation Test with
Espresso
Trần Văn Toàn –
vantoan@planday.com
Table Of Content
 About Espresso
 Espresso Components
 Test case structure
 Custom Matcher and ViewAction
About Espresso
 An user interface testing framework for a single
application
 Run on devices running Android 2.2 and higher
 The Espresso is an instrumentation-based API and
works with the AndroidJUnitRunner test
Espresso - Pros
 Reliable & synchronizes test actions with UI
operations (on the UI thread).
 open to customization with standard hamcrest
matchers
 Clear failure, rich debugging information. Allows
custom failure handler
Espresso - Cons
 Does not support for WebView
 Slow speed since it run on Dalvik VM
 Work with Single application only.
 Solution: Using Espresso combine with uiautomator
Espresso Components
 ViewMatchers: find view based on: id, Tag,
description, text…
withId(R.id.button)
 ViewActions: perform actions on the views
click(), scrollTo()
 ViewAssertions: validate state of a view.
matches(isDisplayed()), doesNotExist()
Test case structure
Find View
 Find the UI component under test in an Activity
by using the onView() or onData() method with a
view matcher which selects the correct view.
Perform Actions
 Call perform() method and passing in the user
action defined by ViewActions class.
 Repeat the steps to simulate a user flow across
multiple activities in the target app
Validate the results
 Call check() method to check expected state or
behavior
 check() method requires a ViewAssertion object
as input
Custom Matcher &
ViewAction Custom Matcher using BoundedMatcher or Hamcrest
framework
Custom Matcher &
ViewAction Custom Action by ViewAction class
THANK FOR WATCHING!
APPENDIX
Add Espresso to project
 install the Android Support Repository
Add Espresso to project
 Config project
Add Espresso to project
 Specify the AndroidJUnitRunner as value for the
testInstrumentationRunner
Construct Test Class and
Methods
References documents
1. https://developer.android.com/training/testing/ui-
testing/espresso-testing.html
2. https://google.github.io/android-testing-support-
library/docs/espresso/
3. http://www.vogella.com/tutorials/AndroidTestingEspresso/artic
le.html
4. http://hamcrest.org/JavaHamcrest/

Contenu connexe

Tendances

Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
Sauce Labs
 
Appium Mobile Test Automation like WebDriver
Appium Mobile Test Automation like WebDriverAppium Mobile Test Automation like WebDriver
Appium Mobile Test Automation like WebDriver
Andrii Dzynia
 

Tendances (20)

ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debuggingATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
ATAGTR2017 Upgrading a mobile tester's weapons with advanced debugging
 
Selenium, Appium, and Robots!
Selenium, Appium, and Robots!Selenium, Appium, and Robots!
Selenium, Appium, and Robots!
 
What's New With Appium? From 1.0 to Now
What's New With Appium? From 1.0 to NowWhat's New With Appium? From 1.0 to Now
What's New With Appium? From 1.0 to Now
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
 
Appium workshop technopark trivandrum
Appium workshop technopark trivandrumAppium workshop technopark trivandrum
Appium workshop technopark trivandrum
 
Cross Platform Appium Tests: How To
Cross Platform Appium Tests: How ToCross Platform Appium Tests: How To
Cross Platform Appium Tests: How To
 
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on WebinarParallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
Parallel Test Runs with Appium on Real Mobile Devices – Hands-on Webinar
 
Automated UI Testing Frameworks
Automated UI Testing FrameworksAutomated UI Testing Frameworks
Automated UI Testing Frameworks
 
Appium & Jenkins
Appium & JenkinsAppium & Jenkins
Appium & Jenkins
 
Appium
AppiumAppium
Appium
 
Appium solution
Appium solutionAppium solution
Appium solution
 
Appium Mobile Test Automation like WebDriver
Appium Mobile Test Automation like WebDriverAppium Mobile Test Automation like WebDriver
Appium Mobile Test Automation like WebDriver
 
Testing Native Apps at PAYBACK
Testing Native Apps at PAYBACKTesting Native Apps at PAYBACK
Testing Native Apps at PAYBACK
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
Espresso
EspressoEspresso
Espresso
 
Appium
AppiumAppium
Appium
 
Vietnam qa meetup
Vietnam qa meetupVietnam qa meetup
Vietnam qa meetup
 
Future of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals itFuture of Mobile Automation, Appium Steals it
Future of Mobile Automation, Appium Steals it
 
Android UI Testing with Espresso
Android UI Testing with EspressoAndroid UI Testing with Espresso
Android UI Testing with Espresso
 

En vedette

MDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation TestMDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation Test
Masud Parvez
 

En vedette (20)

Android Espresso
Android EspressoAndroid Espresso
Android Espresso
 
Screenshots Test spoon + espresso
Screenshots Test spoon + espressoScreenshots Test spoon + espresso
Screenshots Test spoon + espresso
 
Ui testing with espresso
Ui testing with espressoUi testing with espresso
Ui testing with espresso
 
Espresso Barista
Espresso BaristaEspresso Barista
Espresso Barista
 
Android tools for testers
Android tools for testersAndroid tools for testers
Android tools for testers
 
Athena, Android UI Testing Platfrom
Athena, Android UI Testing PlatfromAthena, Android UI Testing Platfrom
Athena, Android UI Testing Platfrom
 
MDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation TestMDC2011 Android_ Webdriver Automation Test
MDC2011 Android_ Webdriver Automation Test
 
Fast deterministic screenshot tests for Android
Fast deterministic screenshot tests for AndroidFast deterministic screenshot tests for Android
Fast deterministic screenshot tests for Android
 
Android development
Android developmentAndroid development
Android development
 
Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?Do You Enjoy Espresso in Android App Testing?
Do You Enjoy Espresso in Android App Testing?
 
Ewa Bielska: Testowanie aplikacji mobilnych
Ewa Bielska: Testowanie aplikacji mobilnychEwa Bielska: Testowanie aplikacji mobilnych
Ewa Bielska: Testowanie aplikacji mobilnych
 
Utilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidUtilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps Android
 
Athena by OLX
Athena by OLXAthena by OLX
Athena by OLX
 
Interview Questions for Mobile application Testing
Interview Questions for Mobile application TestingInterview Questions for Mobile application Testing
Interview Questions for Mobile application Testing
 
Android Test Automation – one year later
Android Test Automation – one year laterAndroid Test Automation – one year later
Android Test Automation – one year later
 
Strategie automatyzacji testow
Strategie automatyzacji testowStrategie automatyzacji testow
Strategie automatyzacji testow
 
Test Automation using Athena by OLX - Intro
Test Automation using Athena by OLX - IntroTest Automation using Athena by OLX - Intro
Test Automation using Athena by OLX - Intro
 
Writing and using Hamcrest Matchers
Writing and using Hamcrest MatchersWriting and using Hamcrest Matchers
Writing and using Hamcrest Matchers
 
Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)
 
Test Driven Development (TDD)
Test Driven Development (TDD)Test Driven Development (TDD)
Test Driven Development (TDD)
 

Similaire à Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn

The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native Apps
Sauce Labs
 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
aspnet123
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
Quontra Solutions
 
VIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUM
VIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUMVIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUM
VIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUM
Vivek Shukla
 

Similaire à Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn (20)

Android testing
Android testingAndroid testing
Android testing
 
Mobile automation testing with selenium and appium
Mobile automation testing with selenium and appiumMobile automation testing with selenium and appium
Mobile automation testing with selenium and appium
 
Better User Experience with .NET
Better User Experience with .NETBetter User Experience with .NET
Better User Experience with .NET
 
10 asp.net session14
10 asp.net session1410 asp.net session14
10 asp.net session14
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 
Selenium Testing Training in Bangalore
Selenium Testing Training in BangaloreSelenium Testing Training in Bangalore
Selenium Testing Training in Bangalore
 
Qa process
Qa processQa process
Qa process
 
Qa process
Qa processQa process
Qa process
 
The Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native AppsThe Future of Selenium Testing for Mobile Web and Native Apps
The Future of Selenium Testing for Mobile Web and Native Apps
 
Automated Acceptance Testing Example
Automated Acceptance Testing ExampleAutomated Acceptance Testing Example
Automated Acceptance Testing Example
 
Coded ui test
Coded ui testCoded ui test
Coded ui test
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Monitoring, troubleshooting,
Monitoring, troubleshooting,Monitoring, troubleshooting,
Monitoring, troubleshooting,
 
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
QA Fest 2014. Ярослав Пернеровский. Appium - два в одном. рецепт приготовлени...
 
Automating with selenium2
Automating with selenium2Automating with selenium2
Automating with selenium2
 
Testes instrumentais. v2
Testes instrumentais. v2Testes instrumentais. v2
Testes instrumentais. v2
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Android Automation Testing with Selendroid
Android Automation Testing with SelendroidAndroid Automation Testing with Selendroid
Android Automation Testing with Selendroid
 
VIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUM
VIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUMVIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUM
VIVEKSHUKLA_10YRS_TESTAUTOMATION_SELENIUM
 
Designing an effective hybrid apps automation framework
Designing an effective hybrid apps automation frameworkDesigning an effective hybrid apps automation framework
Designing an effective hybrid apps automation framework
 

Plus de Nexus FrontierTech

Plus de Nexus FrontierTech (20)

[Executive Lounge Talk] Digital Transformation Journey
[Executive Lounge Talk] Digital Transformation Journey[Executive Lounge Talk] Digital Transformation Journey
[Executive Lounge Talk] Digital Transformation Journey
 
[AI series Talk #2] From PoC to Production - A Case Study
[AI series Talk #2] From PoC to Production - A Case Study[AI series Talk #2] From PoC to Production - A Case Study
[AI series Talk #2] From PoC to Production - A Case Study
 
[AI Series Talk #2] Moving AI from PoC Stage to Production
[AI Series Talk #2] Moving AI from PoC Stage to Production[AI Series Talk #2] Moving AI from PoC Stage to Production
[AI Series Talk #2] Moving AI from PoC Stage to Production
 
[VFS 2019] Introduction to GANs - Pixta Vietnam
[VFS 2019] Introduction to GANs - Pixta Vietnam[VFS 2019] Introduction to GANs - Pixta Vietnam
[VFS 2019] Introduction to GANs - Pixta Vietnam
 
[VFS 2019] Enabling Young Generation for Future - AWS Vietnam User Group
[VFS 2019] Enabling Young Generation for Future - AWS Vietnam User Group[VFS 2019] Enabling Young Generation for Future - AWS Vietnam User Group
[VFS 2019] Enabling Young Generation for Future - AWS Vietnam User Group
 
[VFS 2019] Building chatbot with RASA
[VFS 2019] Building chatbot with RASA[VFS 2019] Building chatbot with RASA
[VFS 2019] Building chatbot with RASA
 
[VFS 2019] Vietnamese Speech-to-Text: Applications and Product
[VFS 2019] Vietnamese Speech-to-Text: Applications and Product[VFS 2019] Vietnamese Speech-to-Text: Applications and Product
[VFS 2019] Vietnamese Speech-to-Text: Applications and Product
 
[VFS 2019] How AI Will Innovate Recruitment
[VFS 2019] How AI Will Innovate Recruitment[VFS 2019] How AI Will Innovate Recruitment
[VFS 2019] How AI Will Innovate Recruitment
 
[VFS 2019] AI in Finance
[VFS 2019] AI in Finance[VFS 2019] AI in Finance
[VFS 2019] AI in Finance
 
[VFS 2019] Preventive Approach to Designing and Selling Healthy AI System
[VFS 2019] Preventive Approach to Designing and Selling Healthy AI System [VFS 2019] Preventive Approach to Designing and Selling Healthy AI System
[VFS 2019] Preventive Approach to Designing and Selling Healthy AI System
 
[VFS 2019] Phương pháp phát hiện bất thường bằng học máy
[VFS 2019] Phương pháp phát hiện bất thường bằng học máy[VFS 2019] Phương pháp phát hiện bất thường bằng học máy
[VFS 2019] Phương pháp phát hiện bất thường bằng học máy
 
[VFS 2019] OCR Techniques for Digital Transformation Evolution
[VFS 2019] OCR Techniques for Digital Transformation Evolution[VFS 2019] OCR Techniques for Digital Transformation Evolution
[VFS 2019] OCR Techniques for Digital Transformation Evolution
 
[VFS 2019] Human Activity Recognition Approaches
[VFS 2019] Human Activity Recognition Approaches [VFS 2019] Human Activity Recognition Approaches
[VFS 2019] Human Activity Recognition Approaches
 
[VFS 2019] Aimesoft Solutions
[VFS 2019] Aimesoft Solutions[VFS 2019] Aimesoft Solutions
[VFS 2019] Aimesoft Solutions
 
[VFS 2019] Datamart Introduction (brief)
[VFS 2019] Datamart Introduction (brief)[VFS 2019] Datamart Introduction (brief)
[VFS 2019] Datamart Introduction (brief)
 
[VFS 2019] Data Strategy for Vietnamese Businesses to Levarage AI
[VFS 2019] Data Strategy for Vietnamese Businesses to Levarage AI[VFS 2019] Data Strategy for Vietnamese Businesses to Levarage AI
[VFS 2019] Data Strategy for Vietnamese Businesses to Levarage AI
 
[VFS 2019] AI for Banks
[VFS 2019] AI for Banks[VFS 2019] AI for Banks
[VFS 2019] AI for Banks
 
[VFS 2019] Digital Solution for Enterprises: 24/7 A.I English Speaking Coach
[VFS 2019] Digital Solution for Enterprises: 24/7 A.I English Speaking Coach[VFS 2019] Digital Solution for Enterprises: 24/7 A.I English Speaking Coach
[VFS 2019] Digital Solution for Enterprises: 24/7 A.I English Speaking Coach
 
[VFS 2019] Project Management for AI-based Product - A Better Approach
[VFS 2019] Project Management for AI-based Product - A Better Approach[VFS 2019] Project Management for AI-based Product - A Better Approach
[VFS 2019] Project Management for AI-based Product - A Better Approach
 
[VFS 2019] AI Ecosystem transition from zero to hero - case study by rubikAI
[VFS 2019] AI Ecosystem transition from zero to hero - case study by rubikAI[VFS 2019] AI Ecosystem transition from zero to hero - case study by rubikAI
[VFS 2019] AI Ecosystem transition from zero to hero - case study by rubikAI
 

Dernier

Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Cara Menggugurkan Kandungan 087776558899
 

Dernier (6)

Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 
Leading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdfLeading Mobile App Development Companies in India (2).pdf
Leading Mobile App Development Companies in India (2).pdf
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
9999266834 Call Girls In Noida Sector 52 (Delhi) Call Girl Service
 
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
Obat Penggugur Kandungan Di Apotik Kimia Farma (087776558899)
 

Tech Talk #5 : Android Automation Test with Espresso - Trần Văn Toàn

Notes de l'éditeur

  1. - The framework also ensures that your activity is started before the tests run. It also let the test wait until all observed background activities have finished. Therefore we Dont have to use sleep, retry or loop
  2. - The framework also ensures that your activity is started before the tests run. It also let the test wait until all observed background activities have finished. Therefore we Dont have to use sleep, retry or loop
  3. - If you are using an AdapterView use the onData() method instead of the onView() method - onView() returns an object of type ViewInteraction. - onData() method returns an object of type DataInteraction.
  4. Perform method has 2 kinds: ViewInteraction.perform(): For normal view DataInteraction.perform(): For view on Adapter The perform method returns again an object of type ViewInteraction > you can perform more actions or validate the result. It also uses varags as argument, i.e, you can pass several actions at the same time to it.
  5. Matches(Matcher <? Super View> matcher) returns ViewA
  6. Hamcrest Matchers, a framework for writing test matcher objects. Go along with Junit 4.1 Use Hamcrest  return TypeSafeMatcher object Use BoundedMatcher  return BoundedMatcher object (same method as Hamcrest)
  7. Hamcrest Matchers, a framework for writing test matcher objects. Go along with Junit 4.1 Use Hamcrest  return TypeSafeMatcher object Use BoundedMatcher  return BoundedMatcher object (same method as Hamcrest)
  8. Matches(Matcher <? Super View> matcher) returns ViewA
  9. Matches(Matcher <? Super View> matcher) returns ViewA
  10. Matches(Matcher <? Super View> matcher) returns ViewA
  11. Matches(Matcher <? Super View> matcher) returns ViewA
  12. Matches(Matcher <? Super View> matcher) returns ViewA