Diese Präsentation wurde erfolgreich gemeldet.
Wir verwenden Ihre LinkedIn Profilangaben und Informationen zu Ihren Aktivitäten, um Anzeigen zu personalisieren und Ihnen relevantere Inhalte anzuzeigen. Sie können Ihre Anzeigeneinstellungen jederzeit ändern.

Android Test Automation Workshop

1.092 Aufrufe

Veröffentlicht am

Support slides for the test automation workshop realized at the iMasters Android DevConference 2015 at São Paulo. The workshop focus was around Unit Tests with JUnit, UI Tests with Espresso and UIAutomator and Testing your app in the cloud with Testdroid.

Veröffentlicht in: Software
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/N3Tcg ◀ ◀ ◀ ◀
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • Get the best essay, research papers or dissertations. from ⇒ www.HelpWriting.net ⇐ A team of professional authors with huge experience will give u a result that will overcome your expectations.
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier
  • D0WNL0AD FULL ▶ ▶ ▶ ▶ http://1lite.top/N3Tcg ◀ ◀ ◀ ◀
       Antworten 
    Sind Sie sicher, dass Sie …  Ja  Nein
    Ihre Nachricht erscheint hier

Android Test Automation Workshop

  1. 1. Íntel Software and Services Group Android:testautomationworkshopEduardo 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 Objective Practice the usage of test automation tools available in the Android Framework through the following activities: • Prepare the test environment for development and execution. • Development of unit tests that run on the local JVM. • Development of UI Tests with Espresso. • Development of Cross Apps Tests with UI Automator. • Running tests in the cloud with TestDroid.
  4. 4. Intel Software and Services Group 4 Requirements • Android Studio 1.3+ • Test Device with Android 4.0+ • SDK Version 23 • Build Tools 23.0.0 • AppCompat-v7 23.3.0
  5. 5. Intel Software and Services Group 5 Base App - BeerWith • Simple demo app to help you keep track of what have you been drinking and with who. • https://github.com/ecarrara-araujo/beer-with • If you want to follow the workshop just clone it and work on branch master. • Check the branch ahead for the implementations: • Imasters-android-devconf-tests-workshop
  6. 6. Intel Software and Services Group #1–CreatingyourfirstUnitTest 6
  7. 7. Intel Software and Services Group 7 #1 – Creating your first Unit Test testCompile 'junit:junit:4.12' • Add the Junit dependency to the app/build.gradle
  8. 8. Intel Software and Services Group 8 #1 – Creating your first Unit Test Create these directories.
  9. 9. Intel Software and Services Group 9 #1 – Creating your first Unit Test
  10. 10. Intel Software and Services Group 10 #1 – Creating your first Unit Test
  11. 11. Intel Software and Services Group 11 #1 – Creating your first Unit Test
  12. 12. Intel Software and Services Group 12 #1 – Creating your first Unit Test public class UtilityTest { @Test public void testGetDateFormattedTime() throws Exception { String expectedDateFormat = "yyyy, MMMM dd"; Calendar calendar = Calendar.getInstance(); calendar.set(2015, 4 - 1, 3); //20150403 String expectedResult = (new SimpleDateFormat(expectedDateFormat)).format(calendar.getTime()); String result = Utility.getDateFormattedTime(calendar, expectedDateFormat); assertEquals("Date was not correctly formatted.", expectedResult, result); // testing a second format to be sure expectedDateFormat = "dd MM yyyy"; expectedResult = (new SimpleDateFormat(expectedDateFormat)).format(calendar.getTime()); result = Utility.getDateFormattedTime(calendar, expectedDateFormat); assertEquals("Date was not correctly formatted.", expectedResult, result); } }
  13. 13. Intel Software and Services Group 13 #1 – Creating your first Unit Test $ ./gradlew testor
  14. 14. Intel Software and Services Group 14 #1 – Creating your first Unit Test or appbuildreportstestsdebugindex.html
  15. 15. Intel Software and Services Group #2Testingtheuiwithespresso 15
  16. 16. Intel Software and Services Group 16 #2 Testing the ui with espresso • App/build.gradle defaultConfig { testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' } 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 allprojects { configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:23.0.0' } }
  17. 17. Intel Software and Services Group 17 #2 Testing the ui with espresso
  18. 18. Intel Software and Services Group 18 #2 Testing the ui with espresso
  19. 19. Intel Software and Services Group 19 #2 Testing the ui with espresso Here comes a whole lot of code… Check the file: BeerWithappsrcandroidTestjavabrengecarrarabeerwit hBeerWithMainActivityInstrumentationTest.java
  20. 20. Intel Software and Services Group 20 #2 Testing the ui with espresso or $ ./gradlew connectedCheck
  21. 21. Intel Software and Services Group 21 #2 Testing the ui with espresso or appbuildreportsandroidTestsconnectedindex.html
  22. 22. Intel Software and Services Group #3CROssappTestingwithUIAutomator 22
  23. 23. Intel Software and Services Group 23 #3 Cross app Testing with UI Automator • App/build.gradle defaultConfig { testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' } • ./build.gradle allprojects { configurations.all { resolutionStrategy.force 'com.android.support:support-annotations:23.0.0' } } dependecies { androidTestCompile 'com.android.support.test:runner:0.3' androidTestCompile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1' androidTestCompile 'org.hamcrest:hamcrest-integration:1.3' }
  24. 24. Intel Software and Services Group 24 #3 Cross app Testing with UI Automator
  25. 25. Intel Software and Services Group 25 #3 Cross app Testing with UI Automator
  26. 26. Intel Software and Services Group 26 #3 Cross app Testing with UI Automator Androidsdk/tools/uiautomatorviewer
  27. 27. Intel Software and Services Group 27 #3 Cross app Testing with UI Automator Here comes a whole lot of code… Check the file: BeerWithappsrcandroidTestjavabrengecarrarabeerwit hAddingBeerWithCompleteTestFlow.java
  28. 28. Intel Software and Services Group 28 #3 Cross app Testing with UI Automator or $ ./gradlew connectedCheck
  29. 29. Intel Software and Services Group 29 or
  30. 30. Intel Software and Services Group 30
  31. 31. Intel Software and Services Group 31
  32. 32. Intel Software and Services Group 32
  33. 33. Intel Software and Services Group 33
  34. 34. Intel Software and Services Group 34
  35. 35. Intel Information Technology What is next? 35 • Follow the guide and automate your tests! • How to integrate continous integration and delivery with Android? • Code Coverage • Mocking
  36. 36. Intel Software and Services Group 36 Intel Developer Zone https://software.intel.com/en-us/android/app-testing
  37. 37. Intel Software and Services Group Thanks! 37 +EduardoCarraraDeAraujo https://www.facebook.com/ducarrara @DuCarrara br.linkedin.com/in/eduardocarrara/ ecarrara-araujo/vilibra
  38. 38. Intel Software and Services Group 38 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
  39. 39. Intel Software and Services Group 39 References • Codelab Android Studio Testing: https://io2015codelabs.appspot.com/codelabs/android- studio-testing#1 • Android Testing Blueprints: https://github.com/googlesamples/android-testing- templates/tree/master/AndroidTestingBlueprint • Testing on Android by Vincent Brison: http://vincentbrison.com/2015/08/05/testing-on- android-part1-a-practical-approach/ • Android Developers Unit Testing Training: https://developer.android.com/training/testing/unit-testing/index.html • Android Testing Samples: https://github.com/googlesamples/android-testing/ • G+ Community: https://plus.google.com/communities/10515313437206298596 • Stack Overflow: http://stackoverflow.com/questions/tagged/android-testing
  40. 40. Intel Software and Services Group 40 References • Espresso v2 Cheat Sheet - https://code.google.com/p/android-test- kit/wiki/EspressoV2CheatSheet
  41. 41. Placeholder Footer Copy / BU Logo or Name Goes Here

×