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.

Testing in Android: automatici, di integrazione, TDD e scenari avanzati

4,369 views

Published on

Published in: Technology

Testing in Android: automatici, di integrazione, TDD e scenari avanzati

  1. 1. Who am I 32 years old happy software developer Mobile addicted Android enthusiastic Free software fan … and Tiramisu' lover rainbowbreeze
  2. 2. Overview Setup the environment Test with Junit 3 Test with special Android mocks Android monkey and monkeyrunner External libraries: Robotium TDD with Robolectric Example of advanced scenario
  3. 3. Setup the environment http://developer.android.com/guide/topics/testing/testing_android.html
  4. 4. Test with Junit 3 <ul><li>Create a class that extends TestCase </li></ul><ul><li>Code first test
  5. 5. Run it! </li></ul>http://developer.android.com/resources/tutorials/testing/helloandroid_test.html
  6. 6. Test with special Android Mock AndroidTestCase (mock context, MoreAsserts) http://developer.android.com/reference/android/test/AndroidTestCase.html http://developer.android.com/reference/android/test/MoreAsserts.html http://developer.android.com/reference/android/test/IsolatedContext.html
  7. 7. Test with special Android Mock ApplicationTestCase (mock context) http://developer.android.com/reference/android/test/ApplicationTestCase.html
  8. 8. Test with special Android Mock ActivityInstrumentationTestCase2 (mock intent) ActivityUnitTestCase (mock context and application) SingleLaunchActivityTestCase (single environment thru tests) ViewAsserts (extended asserts) http://developer.android.com/guide/topics/testing/activity_testing.html http://developer.android.com/resources/tutorials/testing/activity_test.html http://developer.android.com/reference/android/test/ViewAsserts.html
  9. 9. Test with special Android Mock ProviderTestCase2 (mock ontext and application, MockContentResolver) http://developer.android.com/guide/topics/testing/contentprovider_testing.html
  10. 10. Test with special Android Mock ServiceTestCase (mock context and application) test the service lifecycle, not the logic (detached) http://developer.android.com/guide/topics/testing/service_testing.html
  11. 11. Test with special Android Mock MockApplication, MockContext, MockContentProvider (API8), MockCursor (API8), MockDialogInterface, MockPackageManager, MockResources MockContentResolver, IsolatedContext
  12. 12. Android monkey adb shell monkey -p your.package.name -v 500 http://developer.android.com/guide/developing/tools/monkey.html http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html
  13. 13. Android monkeyrunner monkeyrunner writing programs that control an Android device or emulator from outside of Android code. With monkeyrunner, you can write a Python program that installs an Android application or test package, runs it, sends keystrokes to it, takes screenshots of its user interface, and stores screenshots on the workstation http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html
  14. 14. Robotium Automatic black-box test cases for Android applications Your applications or black-box apk http://code.google.com/p/robotium/
  15. 15. TDD with Robolectric Robolectric is a unit test framework that de-fangs the Android SDK jar so you can test-drive the development of your Android app. TDD also for Android (yuppi)! Shadow objects (stock and custom) Integrable with RoboGuice for IoC/DI http://pivotal.github.com/robolectric/
  16. 16. Example of advanced scenario Created a framework for test automation Now QA write XML files corresponding to specific test cases Drastic time redution: from days to 30 minutes Free software! Link to website
  17. 17. Example of advanced scenario Complex and boring test cases to verify upon each release of the product / user stories Android / Blackberry / iPhone tests Junit for logic, but for server integration / different OSes capabilites?
  18. 18. Example of advanced scenario Redefined InstrumentationTestRunner, the new one load xml files and all the tests resources Robot and CommandRunner Xml files define tests to execute It's code, so... Let's the fun begin! ;) https://android-client.forge.funambol.org/

×