Android Unit Testing - Refresher

Course

Today I started Phillip Lackner's course on testing in Android. I've done a bit of testing in the past, but I've never really felt like I've had a good grasp on it as a complete course. I'm hoping this course will help me get a better understanding of testing and how to do it well.

Unit Testing

  • Only test working code so that you can be sure that you don't have to question whether it's the test or the code that's broken
  • The structure of a test case:
    • Test setup: What is given to the test
    • Execution: Run some kind of behaviour
    • Assertion: Check the result matches what you expect

Test types

  • Unit tests: The large majority
    • Tests a single unit of behaviour
  • Integration tests:
    • Tests multiple units of behaviour together
  • End to End tests (UI tests):
    • Tests the user journey through the app

Other tests types:

  • Performance Tests
  • Usability Tests
  • Regression Tests

Hallmarks of good tests

  • Clear and concise
  • Independent
    • Don't share classes
  • Repeatable
    • Always produce the same result
  • Testing speed
  • Comprehensive