Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Utilizando expresso uiautomator na automacao de testes em apps android

711 views

Published on

Executar testes é uma etapa importante do processo de desenvolvimento para garantir níveis de qualidade aceitáveis pelos usuários de sua aplicação. No entanto com o aumento do número de funcionalidades e as frequentes ondas de novos devices esta tarefa tem se tornado cada vez mais árdua, além de extremamente repetitiva, tediosa e sujeita à erros. No mundo Android algumas ferramentas podem lhe auxiliar a automatizar seu processo de testes, o Espresso e o UIAutomator são duas delas que recentemente foram adicionadas ao Android Testing Framework. Nesta palestra trataremos de como utilizar estes frameworks em seu projeto Android para automatizar e simular a interação do usuário com sua app e validar funcionalidades de sua aplicação no processo tornando o seu dia mais legal e produtivo.

Published in: Education
  • Be the first to comment

Utilizando expresso uiautomator na automacao de testes em apps android

  1. 1. Íntel Software and Services Group UsingespressoanduiautomatorEduardo Carrara Developer Evangelist – Intel Developers Relations Division
  2. 2. Intel Software and Services Group #AndroidOnIntel 2 +EduardoCarraraDeAraujo https://www.facebook.com/ducarrara @DuCarrara br.linkedin.com/in/eduardocarrara/ ecarrara-araujo
  3. 3. Intel Software and Services Group 3
  4. 4. Intel Information Technology “I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it.” - Bill Gates 4 Image by Karla Vidal @ http://www.flickr.com/photos/63721650@N00/3661526274 Creative Commons cc-by-2.0
  5. 5. Intel Software and Services Group 5 Challenges AutomationFragmentation
  6. 6. Intel Software and Services Group 6 JUnit UI Automator Android Testing Support Library
  7. 7. Intel Software and Services Group 8 JUnit
  8. 8. Intel Software and Services GroupIntel Information Technology Android Testing Framework 9 • Special TestCases, Asserts e Mocks • MoreAsserts • ViewAsserts • MockApplication • MockContext • MockContentProvider • AndroidTestCase • ActivityInstrumentationTestCase2 • ActivityUnitTestCase • ApplicationTestCase • InstrumentationTestCase • ProviderTestCase • ServiceTestCase • SingleLaunchActivityTestCase JUnit
  9. 9. Intel Software and Services Group Instrumentation 10 • Android Components Context Access; • Components Lifecycle Control; • Component Loading Control; • System Events (e.g.: Broadcasts) • InstrumentationTestRunner • AndroidJUnitRunner • GoogleInstrumentationTestRunner
  10. 10. Intel Software and Services Group Espresso 11 • Simplifies the UI Test Process within your App • Methods for: • View matching • Checks • UI Events
  11. 11. Intel Software and Services Group 12 Espresso - Configuration dependencies { androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test:rules:0.3' androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2' } build.gradle Desabilitar nas opções do desenvolvedor (no device): • Window Animation Scale • Transition Animation Scale • Animator Duration Scale
  12. 12. Intel Software and Services Group 13 Espresso – Vilibra Case • Virtual Librarian • Help to remember the books I lend • How to automate the lend details view? • Class: TestViewLendedBookDetailFlow
  13. 13. Intel Software and Services Group 14 Check the code! Instrumented Test Package: vilibra/app/src/main/androidTest/java/ecarrara/eng/vilibra/ Test Class: TestViewLendedBookDetailFlow.java
  14. 14. Intel Software and Services Group UI Automator 24 • Cross App Testing • Instrumentation Based • Interact with visible elements using descriptors (like text).
  15. 15. Intel Software and Services Group 25 UIAutomator - Configuração build.gradle É necessário inspecionar os componentes visuais das apps alvo para garantir que o UIAutomator consiga localizá-los. Isso significa ter labels de texto visíveis, a propriedade android:contentDescription preenchida, ou ainda a propriedade android:hint (para EditTexts) dependencies { androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test:rules:0.3' androidTestCompile 'com.android.support.test.uiautomator:uiautomator- v18:2.1.1' }
  16. 16. Intel Software and Services Group 1. Extend the InstrumentationTestCase class. 2. Get an instance of UIDevice. 3. Use the method UIDevice.findObject() to get UIObjects and execute Actions. 4. Use asserts to check the results. 26 UIAutomator – Primeiro Test Case
  17. 17. Intel Software and Services Group 27 UIAutomator - uiautomatorviewer
  18. 18. Intel Software and Services Group 28 UIAutomator – Vilibra Case • New case: automate the entire lend process test. • Class: TestLendBookFlow
  19. 19. Intel Software and Services Group 29 Check the code! Instrumented Test Package: vilibra/app/src/main/androidTest/java/ecarrara/eng/vilibra/ Test Class: TestLendBookFlow.java
  20. 20. Intel Software and Services Group 44 Fragmentation Screen size/density variety Different Processor Many OS versions
  21. 21. Intel Software and Services Group 45
  22. 22. Intel Software and Services Group 46
  23. 23. Intel Software and Services Group 47
  24. 24. Intel Information Technology What is next? 52 • Go ahead and automate your app testing! • How to integrate continous integration and delivery with Android? • Code Coverage • Mocking “If you don’t like testing your product, most likely your customers won’t like to test it either.” - Anonymous
  25. 25. Intel Software and Services Group 53 Intel Developer Zone https://software.intel.com/en-us/android/app-testing
  26. 26. Intel Software and Services Group Thanks! 54 +EduardoCarraraDeAraujo https://www.facebook.com/ducarrara @DuCarrara br.linkedin.com/in/eduardocarrara/ ecarrara-araujo/vilibra
  27. 27. Intel Software and Services Group 55 References • Android Testing: https://developer.android.com/tools/testing/testing_android.html • Android Unit Testing Support: http://tools.android.com/tech-docs/unit-testing-support • UI Testing: https://developer.android.com/training/testing/ui-testing/index.html • Android Testing Support Library: https://developer.android.com/tools/testing-support- library • Android Instrumentation: http://developer.android.com/tools/testing/testing_android.html#Instrumentation • Junit: http://junit.org • Testdroid: http://testdroid.com • Intel App Testing Page: https://software.intel.com/en-us/android/app-testing
  28. 28. Intel Software and Services Group 56 Bonus References! Android Testing Support Library (ATSL) • Android Testing Support Library: https://google.github.io/android-testing-support-library/ • Release Announcement: https://plus.google.com/+AndroidDevelopers/posts/SXVtgnoKcAY?linkId=17056826
  29. 29. Placeholder Footer Copy / BU Logo or Name Goes Here

×