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
0
40
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
Tweet
Share
More Decks by Pedro Salomão
See All by Pedro Salomão
Segurança no Desenvolvimento de App`s
ppgsalomao
1
63
Testes Unitários no Android Studio
ppgsalomao
0
110
Persistência com Realm.io
ppgsalomao
4
150
Other Decks in Technology
See All in Technology
Oracle Cloud Infrastructure:2025年6月度サービス・アップデート
oracle4engineer
PRO
2
270
2年でここまで成長!AWSで育てたAI Slack botの軌跡
iwamot
PRO
4
770
Wasm元年
askua
0
150
“社内”だけで完結していた私が、AWS Community Builder になるまで
nagisa53
1
400
Delegating the chores of authenticating users to Keycloak
ahus1
0
130
Node-REDのFunctionノードでMCPサーバーの実装を試してみた / Node-RED × MCP 勉強会 vol.1
you
PRO
0
120
Liquid Glass革新とSwiftUI/UIKit進化
fumiyasac0921
0
240
より良いプロダクトの開発を目指して - 情報を中心としたプロダクト開発 #phpcon #phpcon2025
bengo4com
1
3.1k
Абьюзим random_bytes(). Фёдор Кулаков, разработчик Lamoda Tech
lamodatech
0
350
AIとともに進化するエンジニアリング / Engineering-Evolving-with-AI_final.pdf
lycorptech_jp
PRO
0
110
Amazon ECS & AWS Fargate 運用アーキテクチャ2025 / Amazon ECS and AWS Fargate Ops Architecture 2025
iselegant
17
5.7k
PHPでWebブラウザのレンダリングエンジンを実装する
dip_tech
PRO
0
210
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
30
5.8k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
Mobile First: as difficult as doing things right
swwweet
223
9.7k
How to Ace a Technical Interview
jacobian
277
23k
Documentation Writing (for coders)
carmenintech
72
4.9k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
jQuery: Nuts, Bolts and Bling
dougneiner
63
7.8k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
124
52k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Become a Pro
speakerdeck
PRO
28
5.4k
Typedesign – Prime Four
hannesfritz
42
2.7k
Navigating Team Friction
lara
187
15k
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]