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
48
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
70
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
【FinOps】データドリブンな意思決定を目指して
z63d
3
580
Hatena Engineer Seminar 37 jj1uzh
jj1uzh
0
410
攻撃者がいなくてもAIエージェントはインシデントを起こす
nomizone
0
180
記録をかんたんに、提案をパーソナルに ── AIであすけんが目指すもの
oprstchn
0
110
AIに障害切り分けを全部やってもらった。 。 。 。
estie
0
330
Terraform 101 (初心者向け) 資料
shuadachi
0
160
ゼロをイチにする仕事が終わったあと
smasato
0
170
從觀望到全公司落地:AI Agentic Coding 導入實戰 — 流程整合與安全治理
appleboy
1
490
Kotlin 開発のツラミを爆破した話! / Explode the difficulty of Kotlin dev!
eller86
0
130
どうして今サーバーサイドKotlinを選択したのか
nealle
0
180
GitHub Copilot運用のリアル ~AI Credit時代にどう向き合うか~
takafumisu2uk1
0
600
Fabricをフル活用する AI Agent Hub -製造業特化AIエージェントの設計
iotcomjpadmin
0
190
Featured
See All Featured
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
750
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
230
Thoughts on Productivity
jonyablonski
76
5.2k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
180
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
YesSQL, Process and Tooling at Scale
rocio
174
15k
How to make the Groovebox
asonas
2
2.3k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
230
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.2k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
180
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]