Intro to Unit Testing and UI Testing on Android

http://slides.com/juliansuarez/deck#/

Outline

  • Testing Intro
  • Unit Tests
  • Local Unit Tests
  • Instrumented Unit Tests
  • Code Lab
  • QA
  • Links

Testing Intro

Testing Intro

Software testing is an investigation conducted to provide stakeholders with information about the quality of the product or service under test.

Testing Intro

In general we want to check if the software:

  • Meets the requirements that guided its design and development
  • Responds correctly to all kinds of inputs
  • Performs its functions within an acceptable time
  • Is sufficiently usable
  • can be installed and run in its intended environments, and
    achieves the general result its stakeholders desire

Unit Tests

  • Test indivudual units of source code
  • Typically we try to test a single class isolated from other components of our app

Local Unit Tests

  • Tests run on our local machine NOT on a device or emulator
  • Unit tests are fast!
  • No access to specific Android components (No Context or TextUtils)
  • Dependencies should be mocked using a mocking framework such as Mockito (http://mockito.org/)
  • Local Unit Tests are placed typically on the src/test/java folder on our project

Instrumented Unit Tests

  • These tests run on a Device or Emulator
  • These tests have access to Android specific objects, such as Context
  • Not as fast as local unit tests
  • Instrumented Unit tests are typically placed on the src/androidTest/java folder of our project

Codelab

  • https://codelabs.developers.google.com/codelabs/android-studio-testing/index.html

Codelab

Codelab

STOP ON STEP 6!

QA

LINKS

To handle wating scenarios on Espresso:

  • http://developer.android.com/intl/es/reference/android/support/test/espresso/IdlingResource.html
  • http://blog.sqisland.com/2015/04/espresso-custom-idling-resource.html

 

Best Practices for testing

  • http://developer.android.com/intl/es/training/testing/index.html

 

Made with Slides.com