Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Testing Android Applications

Testing Android Applications

Talk on testing android apps and architecting your android application for testing

Adegeye Mayowa

September 24, 2016
Tweet

More Decks by Adegeye Mayowa

Other Decks in Technology

Transcript

  1. OUTLINE • Why testing • Types of test • What

    to test • Architecting your Android app for testing • Android testing tools • Test driven design • Code lab
  2. REASONS WHY WE DON’T TEST • Tedious • Time consuming

    • What to test? • Unavailability of testing tools and steep learning curve of the available tools.
  3. SOME ADVANTAGES OF TESTING • Checking correctness of app features

    • Improves the design and modularity of the code base • Helps to increase confidence in not breaking existing app functionalities, while refactoring or adding new features to the app
  4. TYPES OF ANDROID TEST UNIT TEST • Tests a small

    and independent piece of code such as a single Class, Interface or a Method • Runs on your machine’s local Java Virtual Machine (JVM) • Located in ‘module-name/src/test/java’
  5. INSTRUMENTED/INTEGRATION TEST • Tests more than one individual module working

    together • Runs on hardware device or emulator • Located in ‘module-name/src/androidTest/java’
  6. WHAT TO TEST • Test business logic independent of any

    framework or library • Test API integration • Test integration with a persistence layer • Test some generic UI components
  7. ARCHITECTING YOUR ANDROID APP FOR TESTING Two major Android app

    architectures are: • MVP - MODEL VIEW PRESENTER • MVVM - MODEL VIEW VIEWMODEL
  8. ANDROID TESTING TOOLS • Android testing support library ◦ AndroidJUnitRunner

    ◦ Espresso ◦ UI Automator • Mockito • Robolectric
  9. TEST DRIVEN DESIGN • Writing test before writing the code

    being tested • Begin by writing a very small test for code that does not exists yet. Run the test, and naturally, it fails. Now write just enough code to make the test pass. No more.
  10. FURTHER READING • Best practices for testing: https://developer.android.com/training/testing/index.html • Testing

    Support Library: https://developer.android.com/topic/libraries/testing-support-library/inde x.html • Espresso cheat sheet: https://google.github.io/android-testing-support-library/docs/espresso/ch eatsheet/index.html • Mockito: http://mockito.org