Testabilidade no android
-
Upload
eduardo-cucharro -
Category
Technology
-
view
147 -
download
0
Transcript of Testabilidade no android
![Page 1: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/1.jpg)
//Testabilidade no Android
/*** Created by Eduardo Cucharro*/
![Page 2: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/2.jpg)
Eduardo Cucharro
//Desenvolvedor desde 2007
//Windows forms
//Web
//Restful Apis
//Processos backend / integrações
//Android
//Grupo Minha Vida (Time Dieta e Saúde)
![Page 3: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/3.jpg)
Por que testar?
![Page 4: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/4.jpg)
92% dos problemas, poderiam ser resolvidos com testes…
![Page 5: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/5.jpg)
O que testar?
![Page 6: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/6.jpg)
//Funcionamento da UI
//Integração entre componentes do próprio app
//Lógica do negócio/aplicação
//Integração com outros apps
//Acesso a dados
//Acesso a REST apis
Coisas a testar
![Page 7: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/7.jpg)
Qual o seu maior problema agora?
![Page 8: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/8.jpg)
//Funcionamento da UI - Espresso
//Integração entre componentes do próprio app - Espresso
//Lógica do negócio/aplicação - JUnit/Mockito
//Integração com outros apps - UI Automator
//Acesso a dados
//Acesso a REST apis
Coisas a testar e com o que testar
![Page 9: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/9.jpg)
Espresso
![Page 10: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/10.jpg)
//Espresso Core - Basic Interaction, Matches Assertions
//Espresso Contrib - RecyclerView, NavDrawer, Picker
//Hamcrest - Muitos outros matches
//Espresso Web - Uso com webviews
//Espresso Idling - Sincronização de Jobs
Espresso libs
![Page 11: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/11.jpg)
Select > act > check
![Page 12: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/12.jpg)
onView(withContentDescription(R.string.lunch))
.perform(scrollTo())
.check(matches(isDisplayed()));
No Espresso
![Page 13: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/13.jpg)
Na prática…?
![Page 14: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/14.jpg)
onView()
onData()
pressBack()
closeSoftKeyboard()
openActionBarOverflowMenu()
isDisplayed()
withText()
withChild()
isDescendantOf()
allOf()
ViewInteractions / ViewMatchers
![Page 15: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/15.jpg)
scrollTo()
click()
swipeRight()
typeText()
longClick()
matches()
not()
startsWith()
hasSize()
is()
ViewActions / ViewAssertions
![Page 16: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/16.jpg)
Hermetic env
![Page 17: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/17.jpg)
Arquitetura não testável
Activity
Fragment
VolleyStatic Helpers
![Page 18: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/18.jpg)
IOC - Service locator
![Page 19: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/19.jpg)
Arquitetura testável
![Page 20: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/20.jpg)
Arquitetura testável
![Page 21: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/21.jpg)
//Separação da lógica e componentes android
//Unit testing
//Testes locais na JVM
//Mais rápido e produtivo
Arquitetura e UnitTesting
![Page 22: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/22.jpg)
Na prática…?
![Page 23: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/23.jpg)
Unit testing -conceitos
![Page 24: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/24.jpg)
//3A - Arrange > Act > Assert
//Mock - Permite testar interações com o objeto
//Stub - Permite simular estado e retorno do objeto
//Fake - Implementação falsa
//Dummy - Objeto sem função (cumprindo tabela)
Nomenclatura em UnitTesting
![Page 25: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/25.jpg)
Na prática…?
![Page 26: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/26.jpg)
Firebase Test Lab
![Page 27: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/27.jpg)
//N Android * N devices * Linguas
//Continuos Integration e ambiente
//Firebase Test Lab pode ajudar
//5$ device/h ou 1$ emulador/h
//Robo Tests Free
Firebase Test Lab - Considerações
![Page 28: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/28.jpg)
Obrigado :)
![Page 29: Testabilidade no android](https://reader034.fdocumentos.tips/reader034/viewer/2022051521/5a6d67dc7f8b9ac2418b6105/html5/thumbnails/29.jpg)
ArrayList<String> aListContatos = new ArrayList<String>();
//Na Comunidade AndroidDevBR (slack)aListContatos.add(“@cuchas“);
//No Twitter
aListContatos.add(“@eduardocucharro“);
//BlogaListContatos.add(“http://cucha.com.br“);
//SlideshareaListContatos.add(“http://www.slideshare.net/eduardocucharro“);
Contatos ;)