Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Espresso 101: Introdução a UI Testing
Search
Pedro Salomão
January 25, 2016
Technology
52
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Espresso 101: Introdução a UI Testing
Introdução a testes de interface gráfica usando o Framework Espresso, da Google.
Pedro Salomão
January 25, 2016
More Decks by Pedro Salomão
See All by Pedro Salomão
Segurança no Desenvolvimento de App`s
ppgsalomao
1
75
Testes Unitários no Android Studio
ppgsalomao
0
130
Persistência com Realm.io
ppgsalomao
4
160
Other Decks in Technology
See All in Technology
JAWS-UG初心者支部#88わいわい初心塾(夏休みの宿題やったかGit編)
otsuki
0
120
[RSJ26] Building a VLA Model Based on Self-Distilled Classification
keio_smilab
PRO
0
190
少人数データチームのDevin活用実践事例
runandy16
2
430
AI活用の現在地、 ちゃんと見えてますか?/XPfest-2026
visional_engineering_and_design
0
130
データエンジニアの困りごとをDevinと一緒に解消する
10xinc
2
790
20260906 「AWS運用入門」著者が教える、運用業務への生成AI活用入門
masaruogura
0
220
Bet AI Day 2026丨Production-Ready AI Agents — エンタープライズの実務を任せるための設計と運用
layerx
PRO
3
2k
Self Healing Rollouts: Automating Production Fixes with Agentic AI
kdubois
0
150
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
150
Bet AI Day 2026丨How We Bet AI: AIとともに働く場をつくる
layerx
PRO
1
2.1k
プロダクト思考 × 基盤思考を AIで実現する Compound Engineering
tkc66buzz
1
240
Claude Codeの体系的な理解と知識のフック
oikon48
10
6.6k
Featured
See All Featured
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
310
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
1
390
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
Between Models and Reality
mayunak
4
450
sira's awesome portfolio website redesign presentation
elsirapls
0
400
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
230
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
340
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.3k
How to build a perfect <img>
jonoalderson
1
5.9k
Tell your own story through comics
letsgokoyo
1
1.1k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Transcript
Espresso 101: Introdução a UI Testing Pedro Salomão @ppgsalomao
[email protected]
/
[email protected]
#whoami
Objetivos
Objetivos 1. Onde entram as diversas ferramentas de teste; 2.
O que são Testes de Interface do Usuário; 3. Como definir o que testar; 4. Como integrar o Espresso ao meu projeto; 5. Como escrever o meu primeiro teste de UI; 6. [BÔNUS] Demo.
Ferramentas para Teste
Camadas da Aplicação USUÁRIO APK INTERNET Interface Gráfica
Ferramentas para Teste Robolectric API 16+ JVM Espresso API 8+
Robotium Calabash Selendroid Instrumentation API 1+ Android Platform Appium UIAutomator API 16+ UIAutomation API 18+
Ferramentas para Teste Robolectric API 16+ JVM Espresso API 8+
Robotium Calabash Selendroid Instrumentation API 1+ Android Platform Appium UIAutomator API 16+ UIAutomation API 18+
Camadas da Aplicação USUÁRIO ESPRESSO APK INTERNET Interface Gráfica
Testes de Interface
Testes de Interface 1. O que devo testar? 2. Qual
o escopo de um teste (método)? 3. Posso testar fluxos completos? 4. E como funciona o estado da aplicação? 5. O que é um Mock e por que é importante?
None
Espresso Processo APK Test APK Espresso
Vamos falar de código?!
Integrando o Espresso
Integrando o Espresso 1. Adicionar no build.gradle, em dependencies: 2.
Adicionar no build.gradle, em android.defaultConfig: compile 'com.android.support:support-annotations:23.1.1' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' androidTestCompile 'com.android.support.test:runner:0.4.1' testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" fonte: https://google.github.io/android-testing-support-library/docs/espresso/setup/index.html
Escrevendo o Teste
Espresso - Asserts onView( ViewMatcher ) .perform( ViewAction ) .check(
ViewAssertion ) fonte: https://google.github.io/android-testing-support-library/docs/espresso/cheatsheet/index.html
ViewMatcher Dois usos básicos: • Encontrar uma view (onView) •
Verificar uma condição da View (matches) Exemplos: • withId( … ) • withText( … ) • isDisplayed()
ViewAction Permite executar ações na tela. Exemplos: • click() •
scrollTo( … ) • typeText( … )
ViewAssertion Permite verificar uma determinada propriedade. Exemplos: • matches( Matcher
) • doesNotExists( … ) • typeText( … ) Observação: doesNotExists() != isNotDisplayed()
Criando um teste Passos para criar um Teste usando Espresso:
• Adicionar a anotação do JUnit na classe. • Adicionar uma Rule para a Activity a ser testada. • Criar os métodos de teste.
Exemplo @RunWith(AndroidJUnit4.class) @LargeTest public class HelloWorldEspressoTest { @Rule public ActivityTestRule<MainActivity>
mActivityRule = new ActivityTestRule<>(MainActivity.class); @Test public void listGoesOverTheFold() { onView(withText("Hello world!”)) .check(matches(isDisplayed())); } }
DEMO
Links Úteis Site da Google para Android Testing https://google.github.io/android-testing-support-library/ Código
do Demo de Espresso https://github.com/ppgsalomao/espresso-examples GTAC 2014: Espresso, Spoon, Wiremock, Oh my! https://www.youtube.com/watch?v=-xQCNf_5NNM Droidcon NYC 2015 - Advanced Android Espresso https://www.youtube.com/watch?v=GlPn60-_txk
Dúvidas?
Obrigado! Pedro Salomão @ppgsalomao
[email protected]
/
[email protected]