Test Dependencies

Before you write your test, you will need to add a couple of tools to your testing environment: Mockito and Hamcrest. Mockito is a Java framework that makes it easy to create simple mock objects. These mock objects will help you isolate your tests of SoundViewModel so that you do not accidentally test other objects at the same time.

Hamcrest is a library of matchers. Matchers are tools that make it easy to match conditions in your code and fail if your code does not match what you expect. You will use them to verify that your code works as you expect it to.

A version of Hamcrest is automatically included with the JUnit library, and JUnit is automatically included as a dependency when you create a new Android ...

Get Android Programming: The Big Nerd Ranch Guide, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.